curt            Fri Jul 16 00:15:30 2004 EDT

  Modified files:              
    /phpdoc/en/language/oop5    static.xml 
  Log:
  The content for the static keyword.
  
  
http://cvs.php.net/diff.php/phpdoc/en/language/oop5/static.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/language/oop5/static.xml
diff -u phpdoc/en/language/oop5/static.xml:1.1 phpdoc/en/language/oop5/static.xml:1.2
--- phpdoc/en/language/oop5/static.xml:1.1      Sun Jul 11 08:33:25 2004
+++ phpdoc/en/language/oop5/static.xml  Fri Jul 16 00:15:30 2004
@@ -1,11 +1,80 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
  <sect1 id="language.oop5.static">
-  <title>Static</title>
+  <title>Static Keyword</title>
+
+  <para>
+   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.
+  </para>
+
   <para>
-   .
+   The static declaration must be after the visibilty declaration. For 
+   compatibility with PHP 4, if no <link
+   linkend="language.oop5.visibility">visibility</link>
+   declaration is used, then the member or method will be treated
+   as if it was declared as <literal>public static</literal>.
   </para>
 
+  <para>
+   Because static methods are callable without an instance of
+   the object created, the pseudo variable <varname>$this</varname> is
+   not available inside the method declared as static.
+  </para>
+
+  <example>
+   <title>Static member example</title>
+   <programlisting role="php">
+<![CDATA[
+<?php
+class Foo {
+  public static $my_static = 'foo';
+
+  public function staticValue() {
+    return self::$my_static;
+  }
+}
+
+class Bar extends Foo {
+
+  public function fooStatic() {
+    return parent::$my_static;
+  }
+}
+
+
+print Foo::$my_static . "\n";
+
+$foo = new Foo();
+print $foo->staticValue() . "\n";
+print $foo->my_static . "\n";      // Undefined my_static 
+
+print Bar::$my_static . "\n";
+$bar = new Bar();
+print $bar->fooStatic() . "\n";
+?>
+]]>
+   </programlisting>
+  </example>
+
+  <example>
+   <title>Static method example</title>
+    <programlisting role="php">
+<![CDATA[
+<?php
+class Foo {
+  public static function aStaticMethod() {
+    // ...
+  }
+}
+
+Foo::aStaticMethod();
+?> 
+]]>
+    </programlisting>
+  </example>
 
  </sect1>
  

Reply via email to