Constants are constant (wow, who would have thought of this?) They do not require an instance of the class. So you can write MyClass::CONSTANT , for example. PDO::FETCH_ASSOC . A property, on the other hand, needs a class, so you need to write $obj = new MyClass; $obj->constant $obj = new MyClass; $obj->constant .
In addition, there are static properties; they do not need an instance ( MyClass::$constant ). And here the difference is that MyClass::$constant can be changed, but MyClass::CONSTANT may not be.)
So, use a constant whenever you have a scalar value without an expression that will not be changed. This is faster than a property, it does not pollute the property namespace, and it is more understandable to anyone reading your code.
source share