Q:

Do public static final class variables exist

In Jave you can define a public static final variable in a class. Is there an equivalent to this in PHP?
I'd like to do the following:
<?php

class MyClass{

    public final static $finalVariable = "something";
}

MyClass::$finalVariable

and not ever have to worry about $finalVariable changing and not having a new instance for every instantiation of MyClass

A:

From this page in the PHP manual:

Note: Properties cannot be declared final, only classes and methods may be declared as final. 

However, you can use class constants as described here.
Your example would look something like this:
<?php

class MyClass{
    const finalVariable = "something";
}

MyClass::finalVariable;
?>

Except of course that finalVariable isn't really an appropriate name because it's not variable =).

A:

There is no such thing as final or readonly keywords/concepts for member variables in PHP OOP. final itself is available for classes themselves and functions contained within only.
What you should consider using instead is a class constant, this will guarantee that the value can not change.
class MyClass
{
    const FINALVARIABLE = "something";
}

// Usage
MyClass::FINALVARIABLE

