|
Scope Resolution Operator (::)The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to a constant, static property, or static method of a class or one of its parents. Moreover, static properties or methods can be overriden via late static binding. When referencing these items from outside the class definition, use the name of the class.
It's possible to reference the class using a variable.
The variable's value can not be a keyword (e.g. Paamayim Nekudotayim would, at first, seem like a strange choice for naming a double-colon. However, while writing the Zend Engine 0.5 (which powers PHP 3), that's what the Zend team decided to call it. It actually does mean double-colon - in Hebrew! Example #1 :: from outside the class definition
Three special keywords self, parent and static are used to access properties or methods from inside the class definition. Example #2 :: from inside the class definition
When an extending class overrides the parent's definition of a method, PHP will not call the parent's method. It's up to the extended class on whether or not the parent's method is called. This also applies to Constructors and Destructors, Overloading, and Magic method definitions. Example #3 Calling a parent's method
See also some examples of static call trickery. |