curt Sat Jul 17 00:51:28 2004 EDT
Modified files:
/phpdoc/en/language/oop5 paamayim-nekudotayim.xml
Log:
paamayim nekudotayim documentation.
http://cvs.php.net/diff.php/phpdoc/en/language/oop5/paamayim-nekudotayim.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/language/oop5/paamayim-nekudotayim.xml
diff -u phpdoc/en/language/oop5/paamayim-nekudotayim.xml:1.1
phpdoc/en/language/oop5/paamayim-nekudotayim.xml:1.2
--- phpdoc/en/language/oop5/paamayim-nekudotayim.xml:1.1 Sun Jul 11 08:33:25
2004
+++ phpdoc/en/language/oop5/paamayim-nekudotayim.xml Sat Jul 17 00:51:27 2004
@@ -1,11 +1,98 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<sect1 id="language.oop5.paamayim-nekudotayim">
<title>::</title>
+
+ <para>
+ The Paamayim Nekudotayim, or in simpler terms, the double colon.
+ This token provides a way to access <link
+ linkend="language.oop5.static">static</link>, <link
+ linkend="language.oop5.constants">constant</link> or overridden members
+ or methods of a class.
+ </para>
+
+ <para>
+ When referencing these items from outside the class definition, you use
+ name of the class.
+ </para>
+
+ <example>
+ <title>:: from outside class definition</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+class MyClass {
+ const CONST_VALUE = 'A constant value';
+}
+echo MyClass::CONST_VALUE;
+?>
+]]>
+ </programlisting>
+ </example>
+
+ <para>
+ Two special keywords <varname>self</varname> and <varname>parent</varname>
+ are used to access members or methods from inside the class definition.
+ </para>
+
+ <example>
+ <title>:: from inside the class definition</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+class OtherClass extends MyClass {
+ public static $my_static = 'static var';
+
+ public static function doubleColon() {
+ echo parent::CONST_VALUE . "\n";
+ echo self::$my_static . "\n";
+ }
+}
+
+OtherClass::doubleColon();
+?>
+]]>
+ </programlisting>
+ </example>
+
<para>
- .
+ When an extending class overrides the parents definition of a method,
+ php will not call the parent's method. It is up to the extending class
+ to call the parent method or not, this also applies to <link
+ linkend="language.oop5.decon">Constructors and Destructors</link>, <link
+ linkend="language.oop5.overloading">Overloading</link> and <link
+ linkend="language.oop5.magic">Magic</link> method defintions as well.
</para>
+ <example>
+ <title>Calling a parent's method</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+class MyClass {
+
+ protected function myFunc() {
+ echo "MyClass::myFunc()\n";
+ }
+}
+
+class OtherClass extends MyClass {
+
+ /* Override parent's definition */
+ public function myFunc() {
+
+ /* But still call the parent function */
+ parent::myFunc();
+ echo "OtherClass::myFunc()\n";
+ }
+}
+
+$class = new OtherClass();
+$class->myFunc();
+?>
+]]>
+ </programlisting>
+ </example>
</sect1>
@@ -29,3 +116,4 @@
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
+