cvs: phpdoc-zh /language/oop5 autoload.xml basic.xml decon.xml
| From: | Dallas Thunder | Date: | Mon, 12 Sep 2005 16:37:48 +0000 |
| Subject: | cvs: phpdoc-zh /language/oop5 autoload.xml basic.xml decon.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-2653@lists.php.net to get a copy of this message | ||
dallas Mon Sep 12 12:37:48 2005 EDT
Added files:
/phpdoc-zh/language/oop5 autoload.xml basic.xml
Modified files:
/phpdoc-zh/language/oop5 decon.xml
Log:
Add new files.
http://cvs.php.net/diff.php/phpdoc-zh/language/oop5/decon.xml?r1=1.7&r2=1.8&ty=u Index: phpdoc-zh/language/oop5/decon.xml diff -u phpdoc-zh/language/oop5/decon.xml:1.7 phpdoc-zh/language/oop5/decon.xml:1.8 --- phpdoc-zh/language/oop5/decon.xml:1.7 Tue Aug 30 17:17:44 2005 +++ phpdoc-zh/language/oop5/decon.xml Mon Sep 12 12:37:46 2005 @@ -1,29 +1,29 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.10 Maintainer: lm92 Status: ready --> - <sect1 id="language.oop5.decon"> - <title>¹¹Ô캯ÊýºÍÎö¹¹º¯Êý</title> +<sect1 id="language.oop5.decon"> + <title>¹¹Ô캯ÊýºÍÎö¹¹º¯Êý</title> - <sect2 id="language.oop5.decon.constructor"> - <title>¹¹Ô캯Êý</title> - <methodsynopsis> - <type>void</type><methodname>__construct</methodname> - <methodparam choice="opt"><type>mixed</type><parameter>args</parameter></methodparam> - <methodparam choice="opt"><parameter>...</parameter></methodparam> - </methodsynopsis> - <para> - PHP 5 ÔÊÐпª·¢ÕßÔÚÒ»¸öÀàÖж¨ÒåÒ»¸ö·½·¨×÷Ϊ¹¹Ô캯Êý¡£¾ßÓй¹Ô캯ÊýµÄÀà»áÔÚÿ´Î´´½¨¶ÔÏóʱÏȵ÷Óô˷½·¨£¬ËùÒԷdz£ÊʺÏÔÚʹÓöÔÏó֮ǰ×öһЩ³õʼ»¯¹¤×÷¡£ - </para> - <note> - <simpara> - Èç¹û×ÓÀàÖж¨ÒåÁ˹¹Ô캯ÊýÔò²»»á°µÖе÷ÓÃÆä¸¸ÀàµÄ¹¹Ô캯Êý¡£ÒªÖ´Ðи¸ÀàµÄ¹¹Ô캯Êý£¬ÐèÒªÔÚ×ÓÀàµÄ¹¹Ô캯ÊýÖе÷Óà - <function>parent::__construct</function>¡£ - </simpara> - </note> - <example> - <title>ʹÓÃбê×¼µÄ¹¹Ô캯Êý</title> - <programlisting role="php"> + <sect2 id="language.oop5.decon.constructor"> + <title>¹¹Ô캯Êý</title> + <methodsynopsis> + <type>void</type><methodname>__construct</methodname> + <methodparam choice="opt"><type>mixed</type><parameter>args</parameter></methodparam> + <methodparam choice="opt"><parameter>...</parameter></methodparam> + </methodsynopsis> + <para> + PHP 5 ÔÊÐпª·¢ÕßÔÚÒ»¸öÀàÖж¨ÒåÒ»¸ö·½·¨×÷Ϊ¹¹Ô캯Êý¡£¾ßÓй¹Ô캯ÊýµÄÀà»áÔÚÿ´Î´´½¨¶ÔÏóʱÏȵ÷Óô˷½·¨£¬ËùÒԷdz£ÊʺÏÔÚʹÓöÔÏó֮ǰ×öһЩ³õʼ»¯¹¤×÷¡£ + </para> + <note> + <simpara> + Èç¹û×ÓÀàÖж¨ÒåÁ˹¹Ô캯ÊýÔò²»»á°µÖе÷ÓÃÆä¸¸ÀàµÄ¹¹Ô캯Êý¡£ÒªÖ´Ðи¸ÀàµÄ¹¹Ô캯Êý£¬ÐèÒªÔÚ×ÓÀàµÄ¹¹Ô캯ÊýÖе÷Óà + <function>parent::__construct</function>¡£ + </simpara> + </note> + <example> + <title>ʹÓÃбê×¼µÄ¹¹Ô캯Êý</title> + <programlisting role="php"> <![CDATA[ <?php class BaseClass { @@ -43,28 +43,28 @@ $obj = new SubClass(); ?> ]]> - </programlisting> - </example> - <para> - ΪÁËʵÏÖÏòºó¼æÈÝÐÔ£¬Èç¹û PHP 5 ÔÚÀàÖÐÕÒ²»µ½ <function>__construct</function> - º¯Êý£¬Ëü¾Í»á³¢ÊÔѰÕÒ¾ÉʽµÄ¹¹Ô캯Êý£¬Ò²¾ÍÊǺÍÀàͬÃûµÄº¯Êý¡£Òò´ËΨһ»á²úÉú¼æÈÝÐÔÎÊÌâµÄÇé¿öÊÇ£ºÀàÖÐÒÑÓÐÒ»¸öÃûΪ - <function>__construct</function> µÄ·½·¨£¬µ«ËüÈ´ÓÖ²»Êǹ¹Ô캯Êý¡£ - </para> - </sect2> - - <sect2 id="language.oop5.decon.destructor"> - <title>Îö¹¹º¯Êý</title> - <methodsynopsis> - <type>void</type><methodname>__destruct</methodname> - <void /> - </methodsynopsis> - <para> - PHP 5 ÒýÈëÁËÎö¹¹º¯ÊýµÄ¸ÅÄÕâÀàËÆÓÚÆäËüÃæÏò¶ÔÏóµÄÓïÑÔ£¬Èç - C++¡£Îö¹¹º¯Êý»áÔÚµ½Ä³¸ö¶ÔÏóµÄËùÓÐÒýÓö¼±»É¾³ý»òÕßµ±¶ÔÏó±»ÏÔʽÏú»ÙʱִÐС£ - </para> - <example> - <title>Îö¹¹º¯ÊýʾÀý</title> - <programlisting role="php"> + </programlisting> + </example> + <para> + ΪÁËʵÏÖÏòºó¼æÈÝÐÔ£¬Èç¹û PHP 5 ÔÚÀàÖÐÕÒ²»µ½ <function>__construct</function> + º¯Êý£¬Ëü¾Í»á³¢ÊÔѰÕÒ¾ÉʽµÄ¹¹Ô캯Êý£¬Ò²¾ÍÊǺÍÀàͬÃûµÄº¯Êý¡£Òò´ËΨһ»á²úÉú¼æÈÝÐÔÎÊÌâµÄÇé¿öÊÇ£ºÀàÖÐÒÑÓÐÒ»¸öÃûΪ + <function>__construct</function> µÄ·½·¨£¬µ«ËüÈ´ÓÖ²»Êǹ¹Ô캯Êý¡£ + </para> + </sect2> + + <sect2 id="language.oop5.decon.destructor"> + <title>Îö¹¹º¯Êý</title> + <methodsynopsis> + <type>void</type><methodname>__destruct</methodname> + <void /> + </methodsynopsis> + <para> + PHP 5 ÒýÈëÁËÎö¹¹º¯ÊýµÄ¸ÅÄÕâÀàËÆÓÚÆäËüÃæÏò¶ÔÏóµÄÓïÑÔ£¬Èç + C++¡£Îö¹¹º¯Êý»áÔÚµ½Ä³¸ö¶ÔÏóµÄËùÓÐÒýÓö¼±»É¾³ý»òÕßµ±¶ÔÏó±»ÏÔʽÏú»ÙʱִÐС£ + </para> + <example> + <title>Îö¹¹º¯ÊýʾÀý</title> + <programlisting role="php"> <![CDATA[ <?php class MyDestructableClass { @@ -81,25 +81,25 @@ $obj = new MyDestructableClass(); ?> ]]> - </programlisting> - </example> + </programlisting> + </example> + <para> + ºÍ¹¹Ô캯ÊýÒ»Ñù£¬¸¸ÀàµÄÎö¹¹º¯Êý²»»á±»ÒýÇæ°µÖе÷Óá£ÒªÖ´Ðи¸ÀàµÄÎö¹¹º¯Êý£¬±ØÐëÔÚ×ÓÀàµÄÎö¹¹º¯ÊýÌåÖÐÏÔʽµ÷Óà + <function>parent::__destruct</function>¡£ + </para> + <note> + <para> + Îö¹¹º¯ÊýÔڽű¾¹Ø±Õʱµ÷Ó㬴ËʱËùÓеÄÍ·ÐÅÏ¢ÒѾ·¢³ö¡£ + </para> + </note> + <note> <para> - ºÍ¹¹Ô캯ÊýÒ»Ñù£¬¸¸ÀàµÄÎö¹¹º¯Êý²»»á±»ÒýÇæ°µÖе÷Óá£ÒªÖ´Ðи¸ÀàµÄÎö¹¹º¯Êý£¬±ØÐëÔÚ×ÓÀàµÄÎö¹¹º¯ÊýÌåÖÐÏÔʽµ÷Óà - <function>parent::__destruct</function>¡£ + ÊÔͼÔÚÎö¹¹º¯ÊýÖÐÅ׳öÒ»¸öÒì³£»áµ¼ÖÂÖÂÃü´íÎó¡£ </para> - <note> - <para> - Îö¹¹º¯ÊýÔڽű¾¹Ø±Õʱµ÷Ó㬴ËʱËùÓеÄÍ·ÐÅÏ¢ÒѾ·¢³ö¡£ - </para> - </note> - <note> - <para> - ÊÔͼÔÚÎö¹¹º¯ÊýÖÐÅ׳öÒ»¸öÒì³£»áµ¼ÖÂÖÂÃü´íÎó¡£ - </para> - </note> - </sect2> + </note> + </sect2> - </sect1> +</sect1> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/co.php/phpdoc-zh/language/oop5/autoload.xml?r=1.1&p=1 Index: phpdoc-zh/language/oop5/autoload.xml +++ phpdoc-zh/language/oop5/autoload.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.6 Maintainer: dallas Status: ready --> <sect1 id="language.oop5.autoload"> <title>×Ô¶¯¼ÓÔØ¶ÔÏó</title> <para> ºÜ¶à¿ª·¢ÕßÐ´ÃæÏò¶ÔÏóµÄÓ¦ÓóÌÐòʱ¶Ôÿ¸öÀàµÄ¶¨Ò彨Á¢Ò»¸ö PHP Ô´Îļþ¡£Ò»¸öºÜ´óµÄ·³ÄÕÊDz»µÃ²»ÔÚÿ¸ö½Å±¾£¨Ã¿¸öÀàÒ»¸öÎļþ£©¿ªÍ·Ð´Ò»¸ö³£³£µÄ°üº¬ÎļþÁÐ±í¡£ </para> <para> ÔÚ PHP 5 ÖУ¬²»ÔÙÐèÒªÕâÑùÁË¡£¿ÉÒÔ¶¨ÒåÒ»¸ö __autoload º¯Êý£¬Ëü»áÔÚÊÔͼʹÓÃÉÐδ±»¶¨ÒåµÄÀàʱ×Ô¶¯µ÷Óá£Í¨¹ýµ÷Óô˺¯Êý£¬½Å±¾ÒýÇæÔÚ PHP ³ö´íʧ°ÜǰÓÐÁË×îºóÒ»¸ö»ú»á¼ÓÔØËùÐèµÄÀà¡£ </para> <note> <para> ÔÚ __autoload º¯ÊýÖÐÅ׳öµÄÒì³£²»Äܱ» <link linkend="language.exceptions">catch</link> Óï¾ä¿é²¶»ñ²¢µ¼ÖÂÖÂÃü´íÎó¡£ </para> </note> <para> <example> <title>Autoload Àý×Ó</title> <para> ±¾Àý³¢ÊÔ·Ö±ð´Ó <filename>MyClass1.php</filename> ºÍ <filename>MyClass2.php</filename> ÎļþÖмÓÔØ <literal>MyClass1</literal> ºÍ <literal>MyClass2</literal> Àà¡£ </para> <programlisting role="php"> <![CDATA[ <?php function __autoload($class_name) { require_once $class_name . '.php'; } $obj = new MyClass1(); $obj2 = new MyClass2(); ?> ]]> </programlisting> </example> </para> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/phpdoc-zh/language/oop5/basic.xml?r=1.1&p=1 Index: phpdoc-zh/language/oop5/basic.xml +++ phpdoc-zh/language/oop5/basic.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.14 Maintainer: dallas Status: ready --> <sect1 id="language.oop5.basic"> <title>»ù±¾¸ÅÄî</title> <sect2 id="language.oop5.basic.class"> <title>class</title> <para> ÿ¸öÀàµÄ¶¨Òå¶¼ÒԹؼü×Ö class ¿ªÍ·£¬ºóÃæ¸ú×ÅÀàÃû£¬¿ÉÒÔÊÇÈÎºÎ·Ç PHP <link linkend="reserved">±£Áô×Ö</link>µÄÃû×Ö¡£ºóÃæ¸ú×ÅÒ»¶Ô»¨À¨ºÅ£¬ÀïÃæ°üº¬ÓÐÀà³ÉÔ±ºÍ·½·¨µÄ¶¨Ò塣α±äÁ¿ <varname>$this</varname> ¿ÉÒÔÔÚµ±Ò»¸ö·½·¨ÔÚ¶ÔÏóÄÚ²¿µ÷ÓÃʱʹÓá£<varname>$this</varname> ÊÇÒ»¸öµ½µ÷ÓöÔÏó£¨Í¨³£ÊÇ·½·¨ËùÊôÓڵĶÔÏ󣬵«Ò²¿ÉÒÔÊÇÁíÒ»¸ö¶ÔÏó£¬Èç¹û¸Ã·½·¨ÊÇ´ÓµÚ¶þ¸ö¶ÔÏóÄÚ<link linkend="language.oop5.static">¾²Ì¬</link>µ÷Óõϰ£©µÄÒýÓ᣿´ÏÂÃæÀý×Ó£º <informalexample> <programlisting role="php"> <![CDATA[ <?php class A { function foo() { if (isset($this)) { echo '$this is defined ('; echo get_class($this); echo ")\n"; } else { echo "\$this is not defined.\n"; } } } class B { function bar() { A::foo(); } } $a = new A(); $a->foo(); A::foo(); $b = new B(); $b->bar(); B::bar(); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ $this is defined (a) $this is not defined. $this is defined (b) $this is not defined. ]]> </screen> </informalexample> </para> <example> <title>¼òµ¥µÄÀඨÒå</title> <programlisting role="php"> <![CDATA[ <?php class SimpleClass { // ³ÉÔ±ÉùÃ÷ public $var = 'a default value'; // ·½·¨ÉùÃ÷ public function displayVar() { echo $this->var; } } ?> ]]> </programlisting> </example> </sect2> <sect2 id="language.oop5.basic.new"> <title>new</title> <para> Òª´´½¨Ò»¸ö¶ÔÏóµÄʵÀý£¬±ØÐë´´½¨Ò»¸öжÔÏó²¢½«Æä¸³¸øÒ»¸ö±äÁ¿¡£µ±´´½¨Ð¶ÔÏóʱ¸Ã¶ÔÏó×ÜÊDZ»¸³Öµ£¬³ý·Ç¸Ã¶ÔÏó¶¨ÒåÁË<link linkend="language.oop5.decon">¹¹Ô캯Êý</link>²¢ÇÒÔÚ³ö´íʱÅ׳öÁËÒ»¸ö<link linkend="language.exceptions">Òì³£</link>¡£ </para> <example> <title>´´½¨Ò»¸öʵÀýe</title> <programlisting role="php"> <![CDATA[ <?php $instance = new SimpleClass() ?> ]]> </programlisting> </example> <para> µ±°ÑÒ»¸ö¶ÔÏóÒѾ´´½¨µÄʵÀý¸³¸øÒ»¸öбäÁ¿Ê±£¬Ð±äÁ¿»á·ÃÎÊͬһ¸öʵÀý£¬¾ÍºÍÓøöÔÏó¸³ÖµÒ»Ñù¡£´ËÐÐΪºÍ¸øº¯Êý´«µÝÈëʵÀýʱһÑù¡£¿ÉÒÔÓÃ<link linkend="language.oop5.cloning">¿Ë¡</link>¸øÒ»¸öÒÑ´´½¨µÄ¶ÔÏó½¨Á¢Ò»¸öÐÂʵÀý¡£ </para> <example> <title>¶ÔÏó¸³Öµ</title> <programlisting role="php"> <![CDATA[ <?php $assigned = $instance; $reference =& $instance; $instance->var = '$assigned will have this value'; $instance = null; // $instance and $reference become null var_dump($instance); var_dump($reference); var_dump($assigned); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ NULL NULL object(SimpleClass)#1 (1) { ["var"]=> string(30) "$assigned will have this value" } ]]> </screen> </example> </sect2> <sect2 id="language.oop5.basic.extends"> <title>extends</title> <para> Ò»¸öÀà¿ÉÒÔÔÚÉùÃ÷ÖÐÓà extends ¹Ø¼ü×ּ̳ÐÁíÒ»¸öÀàµÄ·½·¨ºÍ³ÉÔ±¡£²»ÄÜÀ©Õ¹¶à¸öÀֻ࣬Äܼ̳ÐÒ»¸ö»ùÀà¡£ </para> <para> ±»¼Ì³ÐµÄ·½·¨ºÍ³ÉÔ±¿ÉÒÔͨ¹ýÓÃͬÑùµÄÃû×ÖÖØÐÂÉùÃ÷±»¸²¸Ç£¬³ý·Ç¸¸ÀඨÒå·½·¨Ê±Ê¹ÓÃÁË <link linkend="language.oop5.final">final</link> ¹Ø¼ü×Ö¡£¿ÉÒÔͨ¹ý <link linkend="language.oop5.paamayim-nekudotayim">parent::</link> À´·ÃÎʱ»¸²¸ÇµÄ·½·¨»ò³ÉÔ±¡£ </para> <example> <title>¼òµ¥µÄÀà¼Ì³Ð</title> <programlisting role="php"> <![CDATA[ <?php class ExtendClass extends SimpleClass { // Redefine the parent method function displayVar() { echo "Extending class\n"; parent::displayVar(); } } $extended = new ExtendClass(); $extended->displayVar(); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Extending class a default value ]]> </screen> </example> </sect2> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
http://cvs.php.net/diff.php/phpdoc-zh/language/oop5/decon.xml?r1=1.7&r2=1.8&ty=u Index: phpdoc-zh/language/oop5/decon.xml diff -u phpdoc-zh/language/oop5/decon.xml:1.7 phpdoc-zh/language/oop5/decon.xml:1.8 --- phpdoc-zh/language/oop5/decon.xml:1.7 Tue Aug 30 17:17:44 2005 +++ phpdoc-zh/language/oop5/decon.xml Mon Sep 12 12:37:46 2005 @@ -1,29 +1,29 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.10 Maintainer: lm92 Status: ready --> - <sect1 id="language.oop5.decon"> - <title>¹¹Ô캯ÊýºÍÎö¹¹º¯Êý</title> +<sect1 id="language.oop5.decon"> + <title>¹¹Ô캯ÊýºÍÎö¹¹º¯Êý</title> - <sect2 id="language.oop5.decon.constructor"> - <title>¹¹Ô캯Êý</title> - <methodsynopsis> - <type>void</type><methodname>__construct</methodname> - <methodparam choice="opt"><type>mixed</type><parameter>args</parameter></methodparam> - <methodparam choice="opt"><parameter>...</parameter></methodparam> - </methodsynopsis> - <para> - PHP 5 ÔÊÐпª·¢ÕßÔÚÒ»¸öÀàÖж¨ÒåÒ»¸ö·½·¨×÷Ϊ¹¹Ô캯Êý¡£¾ßÓй¹Ô캯ÊýµÄÀà»áÔÚÿ´Î´´½¨¶ÔÏóʱÏȵ÷Óô˷½·¨£¬ËùÒԷdz£ÊʺÏÔÚʹÓöÔÏó֮ǰ×öһЩ³õʼ»¯¹¤×÷¡£ - </para> - <note> - <simpara> - Èç¹û×ÓÀàÖж¨ÒåÁ˹¹Ô캯ÊýÔò²»»á°µÖе÷ÓÃÆä¸¸ÀàµÄ¹¹Ô캯Êý¡£ÒªÖ´Ðи¸ÀàµÄ¹¹Ô캯Êý£¬ÐèÒªÔÚ×ÓÀàµÄ¹¹Ô캯ÊýÖе÷Óà - <function>parent::__construct</function>¡£ - </simpara> - </note> - <example> - <title>ʹÓÃбê×¼µÄ¹¹Ô캯Êý</title> - <programlisting role="php"> + <sect2 id="language.oop5.decon.constructor"> + <title>¹¹Ô캯Êý</title> + <methodsynopsis> + <type>void</type><methodname>__construct</methodname> + <methodparam choice="opt"><type>mixed</type><parameter>args</parameter></methodparam> + <methodparam choice="opt"><parameter>...</parameter></methodparam> + </methodsynopsis> + <para> + PHP 5 ÔÊÐпª·¢ÕßÔÚÒ»¸öÀàÖж¨ÒåÒ»¸ö·½·¨×÷Ϊ¹¹Ô캯Êý¡£¾ßÓй¹Ô캯ÊýµÄÀà»áÔÚÿ´Î´´½¨¶ÔÏóʱÏȵ÷Óô˷½·¨£¬ËùÒԷdz£ÊʺÏÔÚʹÓöÔÏó֮ǰ×öһЩ³õʼ»¯¹¤×÷¡£ + </para> + <note> + <simpara> + Èç¹û×ÓÀàÖж¨ÒåÁ˹¹Ô캯ÊýÔò²»»á°µÖе÷ÓÃÆä¸¸ÀàµÄ¹¹Ô캯Êý¡£ÒªÖ´Ðи¸ÀàµÄ¹¹Ô캯Êý£¬ÐèÒªÔÚ×ÓÀàµÄ¹¹Ô캯ÊýÖе÷Óà + <function>parent::__construct</function>¡£ + </simpara> + </note> + <example> + <title>ʹÓÃбê×¼µÄ¹¹Ô캯Êý</title> + <programlisting role="php"> <![CDATA[ <?php class BaseClass { @@ -43,28 +43,28 @@ $obj = new SubClass(); ?> ]]> - </programlisting> - </example> - <para> - ΪÁËʵÏÖÏòºó¼æÈÝÐÔ£¬Èç¹û PHP 5 ÔÚÀàÖÐÕÒ²»µ½ <function>__construct</function> - º¯Êý£¬Ëü¾Í»á³¢ÊÔѰÕÒ¾ÉʽµÄ¹¹Ô캯Êý£¬Ò²¾ÍÊǺÍÀàͬÃûµÄº¯Êý¡£Òò´ËΨһ»á²úÉú¼æÈÝÐÔÎÊÌâµÄÇé¿öÊÇ£ºÀàÖÐÒÑÓÐÒ»¸öÃûΪ - <function>__construct</function> µÄ·½·¨£¬µ«ËüÈ´ÓÖ²»Êǹ¹Ô캯Êý¡£ - </para> - </sect2> - - <sect2 id="language.oop5.decon.destructor"> - <title>Îö¹¹º¯Êý</title> - <methodsynopsis> - <type>void</type><methodname>__destruct</methodname> - <void /> - </methodsynopsis> - <para> - PHP 5 ÒýÈëÁËÎö¹¹º¯ÊýµÄ¸ÅÄÕâÀàËÆÓÚÆäËüÃæÏò¶ÔÏóµÄÓïÑÔ£¬Èç - C++¡£Îö¹¹º¯Êý»áÔÚµ½Ä³¸ö¶ÔÏóµÄËùÓÐÒýÓö¼±»É¾³ý»òÕßµ±¶ÔÏó±»ÏÔʽÏú»ÙʱִÐС£ - </para> - <example> - <title>Îö¹¹º¯ÊýʾÀý</title> - <programlisting role="php"> + </programlisting> + </example> + <para> + ΪÁËʵÏÖÏòºó¼æÈÝÐÔ£¬Èç¹û PHP 5 ÔÚÀàÖÐÕÒ²»µ½ <function>__construct</function> + º¯Êý£¬Ëü¾Í»á³¢ÊÔѰÕÒ¾ÉʽµÄ¹¹Ô캯Êý£¬Ò²¾ÍÊǺÍÀàͬÃûµÄº¯Êý¡£Òò´ËΨһ»á²úÉú¼æÈÝÐÔÎÊÌâµÄÇé¿öÊÇ£ºÀàÖÐÒÑÓÐÒ»¸öÃûΪ + <function>__construct</function> µÄ·½·¨£¬µ«ËüÈ´ÓÖ²»Êǹ¹Ô캯Êý¡£ + </para> + </sect2> + + <sect2 id="language.oop5.decon.destructor"> + <title>Îö¹¹º¯Êý</title> + <methodsynopsis> + <type>void</type><methodname>__destruct</methodname> + <void /> + </methodsynopsis> + <para> + PHP 5 ÒýÈëÁËÎö¹¹º¯ÊýµÄ¸ÅÄÕâÀàËÆÓÚÆäËüÃæÏò¶ÔÏóµÄÓïÑÔ£¬Èç + C++¡£Îö¹¹º¯Êý»áÔÚµ½Ä³¸ö¶ÔÏóµÄËùÓÐÒýÓö¼±»É¾³ý»òÕßµ±¶ÔÏó±»ÏÔʽÏú»ÙʱִÐС£ + </para> + <example> + <title>Îö¹¹º¯ÊýʾÀý</title> + <programlisting role="php"> <![CDATA[ <?php class MyDestructableClass { @@ -81,25 +81,25 @@ $obj = new MyDestructableClass(); ?> ]]> - </programlisting> - </example> + </programlisting> + </example> + <para> + ºÍ¹¹Ô캯ÊýÒ»Ñù£¬¸¸ÀàµÄÎö¹¹º¯Êý²»»á±»ÒýÇæ°µÖе÷Óá£ÒªÖ´Ðи¸ÀàµÄÎö¹¹º¯Êý£¬±ØÐëÔÚ×ÓÀàµÄÎö¹¹º¯ÊýÌåÖÐÏÔʽµ÷Óà + <function>parent::__destruct</function>¡£ + </para> + <note> + <para> + Îö¹¹º¯ÊýÔڽű¾¹Ø±Õʱµ÷Ó㬴ËʱËùÓеÄÍ·ÐÅÏ¢ÒѾ·¢³ö¡£ + </para> + </note> + <note> <para> - ºÍ¹¹Ô캯ÊýÒ»Ñù£¬¸¸ÀàµÄÎö¹¹º¯Êý²»»á±»ÒýÇæ°µÖе÷Óá£ÒªÖ´Ðи¸ÀàµÄÎö¹¹º¯Êý£¬±ØÐëÔÚ×ÓÀàµÄÎö¹¹º¯ÊýÌåÖÐÏÔʽµ÷Óà - <function>parent::__destruct</function>¡£ + ÊÔͼÔÚÎö¹¹º¯ÊýÖÐÅ׳öÒ»¸öÒì³£»áµ¼ÖÂÖÂÃü´íÎó¡£ </para> - <note> - <para> - Îö¹¹º¯ÊýÔڽű¾¹Ø±Õʱµ÷Ó㬴ËʱËùÓеÄÍ·ÐÅÏ¢ÒѾ·¢³ö¡£ - </para> - </note> - <note> - <para> - ÊÔͼÔÚÎö¹¹º¯ÊýÖÐÅ׳öÒ»¸öÒì³£»áµ¼ÖÂÖÂÃü´íÎó¡£ - </para> - </note> - </sect2> + </note> + </sect2> - </sect1> +</sect1> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/co.php/phpdoc-zh/language/oop5/autoload.xml?r=1.1&p=1 Index: phpdoc-zh/language/oop5/autoload.xml +++ phpdoc-zh/language/oop5/autoload.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.6 Maintainer: dallas Status: ready --> <sect1 id="language.oop5.autoload"> <title>×Ô¶¯¼ÓÔØ¶ÔÏó</title> <para> ºÜ¶à¿ª·¢ÕßÐ´ÃæÏò¶ÔÏóµÄÓ¦ÓóÌÐòʱ¶Ôÿ¸öÀàµÄ¶¨Ò彨Á¢Ò»¸ö PHP Ô´Îļþ¡£Ò»¸öºÜ´óµÄ·³ÄÕÊDz»µÃ²»ÔÚÿ¸ö½Å±¾£¨Ã¿¸öÀàÒ»¸öÎļþ£©¿ªÍ·Ð´Ò»¸ö³£³£µÄ°üº¬ÎļþÁÐ±í¡£ </para> <para> ÔÚ PHP 5 ÖУ¬²»ÔÙÐèÒªÕâÑùÁË¡£¿ÉÒÔ¶¨ÒåÒ»¸ö __autoload º¯Êý£¬Ëü»áÔÚÊÔͼʹÓÃÉÐδ±»¶¨ÒåµÄÀàʱ×Ô¶¯µ÷Óá£Í¨¹ýµ÷Óô˺¯Êý£¬½Å±¾ÒýÇæÔÚ PHP ³ö´íʧ°ÜǰÓÐÁË×îºóÒ»¸ö»ú»á¼ÓÔØËùÐèµÄÀà¡£ </para> <note> <para> ÔÚ __autoload º¯ÊýÖÐÅ׳öµÄÒì³£²»Äܱ» <link linkend="language.exceptions">catch</link> Óï¾ä¿é²¶»ñ²¢µ¼ÖÂÖÂÃü´íÎó¡£ </para> </note> <para> <example> <title>Autoload Àý×Ó</title> <para> ±¾Àý³¢ÊÔ·Ö±ð´Ó <filename>MyClass1.php</filename> ºÍ <filename>MyClass2.php</filename> ÎļþÖмÓÔØ <literal>MyClass1</literal> ºÍ <literal>MyClass2</literal> Àà¡£ </para> <programlisting role="php"> <![CDATA[ <?php function __autoload($class_name) { require_once $class_name . '.php'; } $obj = new MyClass1(); $obj2 = new MyClass2(); ?> ]]> </programlisting> </example> </para> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/phpdoc-zh/language/oop5/basic.xml?r=1.1&p=1 Index: phpdoc-zh/language/oop5/basic.xml +++ phpdoc-zh/language/oop5/basic.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.14 Maintainer: dallas Status: ready --> <sect1 id="language.oop5.basic"> <title>»ù±¾¸ÅÄî</title> <sect2 id="language.oop5.basic.class"> <title>class</title> <para> ÿ¸öÀàµÄ¶¨Òå¶¼ÒԹؼü×Ö class ¿ªÍ·£¬ºóÃæ¸ú×ÅÀàÃû£¬¿ÉÒÔÊÇÈÎºÎ·Ç PHP <link linkend="reserved">±£Áô×Ö</link>µÄÃû×Ö¡£ºóÃæ¸ú×ÅÒ»¶Ô»¨À¨ºÅ£¬ÀïÃæ°üº¬ÓÐÀà³ÉÔ±ºÍ·½·¨µÄ¶¨Ò塣α±äÁ¿ <varname>$this</varname> ¿ÉÒÔÔÚµ±Ò»¸ö·½·¨ÔÚ¶ÔÏóÄÚ²¿µ÷ÓÃʱʹÓá£<varname>$this</varname> ÊÇÒ»¸öµ½µ÷ÓöÔÏó£¨Í¨³£ÊÇ·½·¨ËùÊôÓڵĶÔÏ󣬵«Ò²¿ÉÒÔÊÇÁíÒ»¸ö¶ÔÏó£¬Èç¹û¸Ã·½·¨ÊÇ´ÓµÚ¶þ¸ö¶ÔÏóÄÚ<link linkend="language.oop5.static">¾²Ì¬</link>µ÷Óõϰ£©µÄÒýÓ᣿´ÏÂÃæÀý×Ó£º <informalexample> <programlisting role="php"> <![CDATA[ <?php class A { function foo() { if (isset($this)) { echo '$this is defined ('; echo get_class($this); echo ")\n"; } else { echo "\$this is not defined.\n"; } } } class B { function bar() { A::foo(); } } $a = new A(); $a->foo(); A::foo(); $b = new B(); $b->bar(); B::bar(); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ $this is defined (a) $this is not defined. $this is defined (b) $this is not defined. ]]> </screen> </informalexample> </para> <example> <title>¼òµ¥µÄÀඨÒå</title> <programlisting role="php"> <![CDATA[ <?php class SimpleClass { // ³ÉÔ±ÉùÃ÷ public $var = 'a default value'; // ·½·¨ÉùÃ÷ public function displayVar() { echo $this->var; } } ?> ]]> </programlisting> </example> </sect2> <sect2 id="language.oop5.basic.new"> <title>new</title> <para> Òª´´½¨Ò»¸ö¶ÔÏóµÄʵÀý£¬±ØÐë´´½¨Ò»¸öжÔÏó²¢½«Æä¸³¸øÒ»¸ö±äÁ¿¡£µ±´´½¨Ð¶ÔÏóʱ¸Ã¶ÔÏó×ÜÊDZ»¸³Öµ£¬³ý·Ç¸Ã¶ÔÏó¶¨ÒåÁË<link linkend="language.oop5.decon">¹¹Ô캯Êý</link>²¢ÇÒÔÚ³ö´íʱÅ׳öÁËÒ»¸ö<link linkend="language.exceptions">Òì³£</link>¡£ </para> <example> <title>´´½¨Ò»¸öʵÀýe</title> <programlisting role="php"> <![CDATA[ <?php $instance = new SimpleClass() ?> ]]> </programlisting> </example> <para> µ±°ÑÒ»¸ö¶ÔÏóÒѾ´´½¨µÄʵÀý¸³¸øÒ»¸öбäÁ¿Ê±£¬Ð±äÁ¿»á·ÃÎÊͬһ¸öʵÀý£¬¾ÍºÍÓøöÔÏó¸³ÖµÒ»Ñù¡£´ËÐÐΪºÍ¸øº¯Êý´«µÝÈëʵÀýʱһÑù¡£¿ÉÒÔÓÃ<link linkend="language.oop5.cloning">¿Ë¡</link>¸øÒ»¸öÒÑ´´½¨µÄ¶ÔÏó½¨Á¢Ò»¸öÐÂʵÀý¡£ </para> <example> <title>¶ÔÏó¸³Öµ</title> <programlisting role="php"> <![CDATA[ <?php $assigned = $instance; $reference =& $instance; $instance->var = '$assigned will have this value'; $instance = null; // $instance and $reference become null var_dump($instance); var_dump($reference); var_dump($assigned); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ NULL NULL object(SimpleClass)#1 (1) { ["var"]=> string(30) "$assigned will have this value" } ]]> </screen> </example> </sect2> <sect2 id="language.oop5.basic.extends"> <title>extends</title> <para> Ò»¸öÀà¿ÉÒÔÔÚÉùÃ÷ÖÐÓà extends ¹Ø¼ü×ּ̳ÐÁíÒ»¸öÀàµÄ·½·¨ºÍ³ÉÔ±¡£²»ÄÜÀ©Õ¹¶à¸öÀֻ࣬Äܼ̳ÐÒ»¸ö»ùÀà¡£ </para> <para> ±»¼Ì³ÐµÄ·½·¨ºÍ³ÉÔ±¿ÉÒÔͨ¹ýÓÃͬÑùµÄÃû×ÖÖØÐÂÉùÃ÷±»¸²¸Ç£¬³ý·Ç¸¸ÀඨÒå·½·¨Ê±Ê¹ÓÃÁË <link linkend="language.oop5.final">final</link> ¹Ø¼ü×Ö¡£¿ÉÒÔͨ¹ý <link linkend="language.oop5.paamayim-nekudotayim">parent::</link> À´·ÃÎʱ»¸²¸ÇµÄ·½·¨»ò³ÉÔ±¡£ </para> <example> <title>¼òµ¥µÄÀà¼Ì³Ð</title> <programlisting role="php"> <![CDATA[ <?php class ExtendClass extends SimpleClass { // Redefine the parent method function displayVar() { echo "Extending class\n"; parent::displayVar(); } } $extended = new ExtendClass(); $extended->displayVar(); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Extending class a default value ]]> </screen> </example> </sect2> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->