Constants
A constant is a value that never changes. It is unlike a variable which can be readily changed.

- A class can define constants. Since constant values can not be changed all objects of the class will share the same value.
- Constants are accessed using the class name, NOT thru the object.
- Use the scope resolution operator :: (double colon) aka Paamayim Nekudotayim.
- As with static members, constant values cannot be accessed from an instance of the object (using $objectNameHere::constant).
- It is unneccesary to make constants private or protected since their values can not be changed.

- There a good explanation of constants here.

0 Comments:
Post a Comment
<< Home