PHP Question

Jake

Paragon
Joined
Nov 14, 2010
Messages
2,264
Reaction score
2
FP$
246
Hey PHP gurus...question for ya.

When using classes, let's say:

Code:
class Doggy {
}

for example...and you need a method/variable that cannot change, I know to use the final keyword along with the scope keyword, but does placement matter?

For example, when I code in Java I can do:

Code:
public final

but in PHP it looks like it needs to be:

Code:
final public

I just don't like the look and feel of this.

Can it go both ways?

Thanks!
 
public final would work on PHP as well. Its just that PHP documentation says final public in examples and most people follow it. 🙂
 
Though it's better to use a class constant if it's never going to change 🙂

Code:
class MyClass {
    const SOME_VAR = '123';
}
 
Back
Top Bottom