|
Declaring class members or methods as static, makes them callable from outside the object context. A member or method declared with static can not be accessed with a variable that is an instance of the object and cannot be re-defined in an extending class.
The static declaration must be after the visibility declaration. For compatibility with PHP 4, if no visibility declaration is used, then the member or method will be treated as if it was declared as public static.
Because static methods are callable without an instance of the object created, the pseudo variable $this is not available inside the method declared as static.
In fact static method calls are resolved at compile time. When using an explicit class name the method is already identified completley and no inheritance rules apply. If the call is done by self then self is translated to the current class, that is the class the code belongs to. Here also no inheritance rules apply.
Static properties cannot be accessed through the object using the arrow operator ->.
Poprzedni | Spis treści | Następny |
Scope Resolution Operator (::) | Początek rozdziału | Object Constants |
Hosting by: Hurra Communications Sp. z o.o.
Generated: 2007-01-26 18:02:39