From d62a61a0768a2a8e788b65256ea8516e519a565e Mon Sep 17 00:00:00 2001 From: Curt Zirzow Date: Fri, 16 Jul 2004 04:15:30 +0000 Subject: [PATCH] The content for the static keyword. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@163427 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/oop5/static.xml | 75 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/language/oop5/static.xml b/language/oop5/static.xml index 158147210b..adf0aa3618 100644 --- a/language/oop5/static.xml +++ b/language/oop5/static.xml @@ -1,11 +1,80 @@ - + - Static + Static Keyword + - . + 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 visibilty 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. + + + + Static member example + +staticValue() . "\n"; +print $foo->my_static . "\n"; // Undefined my_static + +print Bar::$my_static . "\n"; +$bar = new Bar(); +print $bar->fooStatic() . "\n"; +?> +]]> + + + + + Static method example + + +]]> + +