cvs: phpdoc-zh /reference/classobj/functions get-declared-classes.xml get-object-vars.xml get-parent-class.xml is-a.xml is-subclass-of.xml
method-exists.xml
| From: | Dallas Thunder | Date: | Fri, 20 Jan 2006 04:26:35 +0000 |
| Subject: | cvs: phpdoc-zh /reference/classobj/functions get-declared-classes.xml get-object-vars.xml get-parent-class.xml is-a.xml is-subclass-of.xml method-exists.xml |
||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-2750@lists.php.net to get a copy of this message | ||
dallas Fri Jan 20 04:26:35 2006 UTC
Modified files:
/phpdoc-zh/reference/classobj/functions get-declared-classes.xml
get-object-vars.xml
get-parent-class.xml
is-a.xml is-subclass-of.xml
method-exists.xml
Log:
Updated.
http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/get-declared-classes.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc-zh/reference/classobj/functions/get-declared-classes.xml diff -u phpdoc-zh/reference/classobj/functions/get-declared-classes.xml:1.1 phpdoc-zh/reference/classobj/functions/get-declared-classes.xml:1.2 --- phpdoc-zh/reference/classobj/functions/get-declared-classes.xml:1.1 Tue Apr 1 12:46:46 2003 +++ phpdoc-zh/reference/classobj/functions/get-declared-classes.xml Fri Jan 20 04:26:35 2006 @@ -1,41 +1,64 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.3 Maintainer: nio Status: ready --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.6 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.11 --> - <refentry id="function.get-declared-classes"> - <refnamediv> - <refname>get_declared_classes</refname> - <refpurpose>·µ»ØÓÉÒѶ¨ÒåÀàµÄÃû×ÖËù×é³ÉµÄÊý×é</refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>array</type><methodname>get_declared_classes</methodname> - <void/> - </methodsynopsis> - <para> - ·µ»ØÓɵ±Ç°½Å±¾ÖÐÒѶ¨ÒåÀàµÄÃû×Ö×é³ÉµÄÊý×é¡£ - </para> - <note> - <para> - ÔÚ PHP 4.0.1pl2 ÖУ¬ÓÐÈý¸ö¶îÍâµÄÀà´æÔÚÓÚ·µ»ØµÄÊý×éÖУº<classname>stdClass</classname>£¨ÔÚ - <filename>Zend/zend.c</filename> Öж¨Ò壩¡¢<classname>OverloadedTestClass</classname>£¨ÔÚ - <filename>ext/standard/basic_functions.c</filename> Öж¨Ò壩ºÍ - <classname>Directory</classname>£¨ÔÚ<filename> ext/standard/dir.c</filename> Öж¨Ò壩¡£ - </para> - <para> - »¹ÐèҪעÒâµÄÊǶîÍâÀàµÄ³öÏÖÒÀÀµÓÚÄãÒѱàÒëµ½ PHP - ÖеĿ⡣ÕâÒâζ×ÅÄã²»ÄÜʹÓÃÕâЩÀàÃû¶¨Òå×Ô¼ºµÄÀà¡£ÔÚ¸½Â¼µÄ - <link linkend="reserved.classes">Ô¤¶¨ÒåÀà</link> - ²¿·ÖÓÐÔ¤¶¨ÒåÀàµÄÁÐ±í¡£ - </para> - </note> - <simpara> - ²Î¼û <function>class_exists</function>¡£ - </simpara> - </refsect1> - </refentry> +<refentry id="function.get-declared-classes"> + <refnamediv> + <refname>get_declared_classes</refname> + <refpurpose>·µ»ØÓÉÒѶ¨ÒåÀàµÄÃû×ÖËù×é³ÉµÄÊý×é</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>array</type><methodname>get_declared_classes</methodname> + <void/> + </methodsynopsis> + <para> + ·µ»ØÓɵ±Ç°½Å±¾ÖÐÒѶ¨ÒåÀàµÄÃû×Ö×é³ÉµÄÊý×é¡£ + </para> + <note> + <para> + ÔÚ PHP 4.0.1pl2 ÖУ¬ÓÐÈý¸ö¶îÍâµÄÀà´æÔÚÓÚ·µ»ØµÄÊý×éÖУº<classname>stdClass</classname>£¨ÔÚ + <filename>Zend/zend.c</filename> Öж¨Ò壩¡¢<classname>OverloadedTestClass</classname>£¨ÔÚ + <filename>ext/standard/basic_functions.c</filename> Öж¨Ò壩ºÍ + <classname>Directory</classname>£¨ÔÚ<filename> ext/standard/dir.c</filename> Öж¨Ò壩¡£ + </para> + <para> + »¹ÐèҪעÒâµÄÊǶîÍâÀàµÄ³öÏÖÒÀÀµÓÚÄãÒѱàÒëµ½ PHP + ÖеĿ⡣ÕâÒâζ×ÅÄã²»ÄÜʹÓÃÕâЩÀàÃû¶¨Òå×Ô¼ºµÄÀà¡£ÔÚ¸½Â¼µÄ + <link linkend="reserved.classes">Ô¤¶¨ÒåÀà</link> + ²¿·ÖÓÐÔ¤¶¨ÒåÀàµÄÁÐ±í¡£ + </para> + </note> + <para> + <example> + <title><function>get_declared_classes</function> Àý×Ó</title> + <programlisting role="php"> +<![CDATA[ +<?php +print_r(get_declared_classes()); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Array +( + [0] => stdClass + [1] => __PHP_Incomplete_Class + [2] => Directory +) +]]> + </screen> + </example> + </para> + <simpara> + ²Î¼û <function>class_exists</function> ºÍ <function>get_declared_interfaces</function>¡£ + </simpara> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/get-object-vars.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc-zh/reference/classobj/functions/get-object-vars.xml diff -u phpdoc-zh/reference/classobj/functions/get-object-vars.xml:1.1 phpdoc-zh/reference/classobj/functions/get-object-vars.xml:1.2 --- phpdoc-zh/reference/classobj/functions/get-object-vars.xml:1.1 Tue Apr 1 13:09:24 2003 +++ phpdoc-zh/reference/classobj/functions/get-object-vars.xml Fri Jan 20 04:26:35 2006 @@ -1,51 +1,53 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.3 Maintainer: nio Status: ready --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.8 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.1 --> - <refentry id="function.get-object-vars"> - <refnamediv> - <refname>get_object_vars</refname> - <refpurpose>·µ»ØÓɶÔÏóÊôÐÔ×é³ÉµÄ¹ØÁªÊý×é</refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>array</type><methodname>get_object_vars</methodname> - <methodparam><type>object</type><parameter>obj</parameter></methodparam> - </methodsynopsis> - <para> - ·µ»ØÓÉ <parameter>obj</parameter> - Ö¸¶¨µÄ¶ÔÏóÖж¨ÒåµÄÊôÐÔ×é³ÉµÄ¹ØÁªÊý×é¡£ - </para> - <note> - <para> - ÔÚ PHP 4.2.0 ֮ǰµÄ°æ±¾ÖУ¬Èç¹ûÔÚ <parameter>obj</parameter> - ¶ÔÏóʵÀýÖÐÉùÃ÷µÄ±äÁ¿Ã»Óб»¸³Öµ£¬ÔòËüÃǽ«²»»áÔÚ·µ»ØµÄÊý×éÖС£¶øÔÚ - PHP 4.2.0 Ö®ºó£¬ÕâЩ±äÁ¿×÷Ϊ¼üÃû½«±»¸³Óè <constant>NULL</constant> - Öµ¡£ - </para> - </note> - <para> - <example> - <title>ʹÓà <function>get_object_vars</function></title> - <programlisting role="php"> +<refentry id="function.get-object-vars"> + <refnamediv> + <refname>get_object_vars</refname> + <refpurpose>·µ»ØÓɶÔÏóÊôÐÔ×é³ÉµÄ¹ØÁªÊý×é</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>array</type><methodname>get_object_vars</methodname> + <methodparam><type>object</type><parameter>obj</parameter></methodparam> + </methodsynopsis> + <para> + ·µ»ØÓÉ <parameter>obj</parameter> + Ö¸¶¨µÄ¶ÔÏóÖж¨ÒåµÄÊôÐÔ×é³ÉµÄ¹ØÁªÊý×é¡£ + </para> + <note> + <para> + ÔÚ PHP 4.2.0 ֮ǰµÄ°æ±¾ÖУ¬Èç¹ûÔÚ <parameter>obj</parameter> + ¶ÔÏóʵÀýÖÐÉùÃ÷µÄ±äÁ¿Ã»Óб»¸³Öµ£¬ÔòËüÃǽ«²»»áÔÚ·µ»ØµÄÊý×éÖС£¶øÔÚ + PHP 4.2.0 Ö®ºó£¬ÕâЩ±äÁ¿×÷Ϊ¼üÃû½«±»¸³Óè &null; Öµ¡£ + </para> + </note> + <para> + <example> + <title>ʹÓà <function>get_object_vars</function></title> + <programlisting role="php"> <![CDATA[ <?php class Point2D { var $x, $y; var $label; - function Point2D($x, $y) { + function Point2D($x, $y) + { $this->x = $x; $this->y = $y; } - function setLabel($label) { + function setLabel($label) + { $this->label = $label; } - function getPoint() { + function getPoint() + { return array("x" => $this->x, "y" => $this->y, "label" => $this->label); @@ -61,10 +63,9 @@ ?> ]]> - </programlisting> - </example> - ÉϱߵijÌÐò½«Êä³ö£º - <screen> + </programlisting> + &example.outputs; + <screen> <![CDATA[ Array ( @@ -80,14 +81,15 @@ [label] => point #1 ) ]]> - </screen> - </para> - <simpara> - ²Î¼û <function>get_class_methods</function> ºÍ - <function>get_class_vars</function>£¡ - </simpara> - </refsect1> - </refentry> + </screen> + </example> + </para> + <simpara> + ²Î¼û <function>get_class_methods</function> ºÍ + <function>get_class_vars</function>¡£ + </simpara> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/get-parent-class.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc-zh/reference/classobj/functions/get-parent-class.xml diff -u phpdoc-zh/reference/classobj/functions/get-parent-class.xml:1.1 phpdoc-zh/reference/classobj/functions/get-parent-class.xml:1.2 --- phpdoc-zh/reference/classobj/functions/get-parent-class.xml:1.1 Tue Apr 1 13:17:25 2003 +++ phpdoc-zh/reference/classobj/functions/get-parent-class.xml Fri Jan 20 04:26:35 2006 @@ -1,35 +1,83 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.2 Maintainer: nio Status: ready --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.7 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.4 --> - <refentry id="function.get-parent-class"> - <refnamediv> - <refname>get_parent_class</refname> - <refpurpose>·µ»Ø¶ÔÏó»òÀàµÄ¸¸ÀàÃû</refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>string</type><methodname>get_parent_class</methodname> - <methodparam><type>mixed</type><parameter>obj</parameter></methodparam> - </methodsynopsis> - <para> - Èç¹û <parameter>obj</parameter> - ÊǶÔÏó£¬Ôò·µ»Ø¶ÔÏóʵÀý <parameter>obj</parameter> - ËùÊôÀàµÄ¸¸ÀàÃû¡£ - </para> - <para> - Èç¹û <parameter>obj</parameter> - ÊÇ×Ö·û´®£¬Ôò·µ»ØÒÔ´Ë×Ö·û´®ÎªÃûµÄÀàµÄ¸¸ÀàÃû¡£´Ë¹¦ÄÜÊÇÔÚ - PHP 4.0.5 ÖÐÔö¼ÓµÄ¡£ - </para> - <simpara> - ²Î¼û <function>get_class</function> ºÍ - <function>is_subclass_of</function> - </simpara> - </refsect1> - </refentry> +<refentry id="function.get-parent-class"> + <refnamediv> + <refname>get_parent_class</refname> + <refpurpose>·µ»Ø¶ÔÏó»òÀàµÄ¸¸ÀàÃû</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>string</type><methodname>get_parent_class</methodname> + <methodparam choice="opt"><type>mixed</type><parameter>obj</parameter></methodparam> + </methodsynopsis> + <para> + Èç¹û <parameter>obj</parameter> + ÊǶÔÏó£¬Ôò·µ»Ø¶ÔÏóʵÀý <parameter>obj</parameter> + ËùÊôÀàµÄ¸¸ÀàÃû¡£ + </para> + <para> + Èç¹û <parameter>obj</parameter> + ÊÇ×Ö·û´®£¬Ôò·µ»ØÒÔ´Ë×Ö·û´®ÎªÃûµÄÀàµÄ¸¸ÀàÃû¡£´Ë¹¦ÄÜÊÇÔÚ + PHP 4.0.5 ÖÐÔö¼ÓµÄ¡£ + </para> + <note> + <para> + ×Ô PHP 5 Æð£¬Èç¹ûÔÚ¶ÔÏóµÄ·½·¨ÄÚµ÷Óã¬Ôò <parameter>obj</parameter> Ϊ¿ÉÑ¡Ïî¡£ + </para> + </note> + <para> + <example> + <title>ʹÓà <function>get_parent_class</function></title> + <programlisting role="php"> +<![CDATA[ +<?php + +class dad { + function dad() + { + // implements some logic + } +} + +class child extends dad { + function child() + { + echo "I'm " , get_parent_class($this) , "'s son\n"; + } +} + +class child2 extends dad { + function child2() + { + echo "I'm " , get_parent_class('child2') , "'s son too\n"; + } +} + +$foo = new child(); +$bar = new child2(); + +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +I'm dad's son +I'm dad's son too +]]> + </screen> + </example> + </para> + <para> + ²Î¼û <function>get_class</function> ºÍ + <function>is_subclass_of</function>¡£ + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/is-a.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc-zh/reference/classobj/functions/is-a.xml diff -u phpdoc-zh/reference/classobj/functions/is-a.xml:1.2 phpdoc-zh/reference/classobj/functions/is-a.xml:1.3 --- phpdoc-zh/reference/classobj/functions/is-a.xml:1.2 Tue Apr 1 13:51:18 2003 +++ phpdoc-zh/reference/classobj/functions/is-a.xml Fri Jan 20 04:26:35 2006 @@ -1,32 +1,71 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.2 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.3 Maintainer: nio Status: ready --> +<!-- $Revision: 1.3 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.7 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.33 --> - <refentry id="function.is-a"> - <refnamediv> - <refname>is_a</refname> - <refpurpose> - Èç¹û¶ÔÏóÊôÓÚ¸ÃÀà»ò¸ÃÀàÊǴ˶ÔÏóµÄ¸¸ÀàÔò·µ»Ø &true; - </refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>bool</type><methodname>is_a</methodname> - <methodparam><type>object</type><parameter>object</parameter></methodparam> - <methodparam><type>string</type><parameter>class_name</parameter></methodparam> - </methodsynopsis> - <para> - Èç¹û¶ÔÏóÊǸÃÀà»ò¸ÃÀàÊǴ˶ÔÏóµÄ¸¸ÀàÔò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ - </para> - <simpara> - ²Î¼û <function>get_class</function>¡¢ - <function>get_parent_class</function> ºÍ - <function>is_subclass_of</function>¡£ - </simpara> - </refsect1> - </refentry> +<refentry id="function.is-a"> + <refnamediv> + <refname>is_a</refname> + <refpurpose>Èç¹û¶ÔÏóÊôÓÚ¸ÃÀà»ò¸ÃÀàÊǴ˶ÔÏóµÄ¸¸ÀàÔò·µ»Ø &true;</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>bool</type><methodname>is_a</methodname> + <methodparam><type>object</type><parameter>object</parameter></methodparam> + <methodparam><type>string</type><parameter>class_name</parameter></methodparam> + </methodsynopsis> + <para> + Èç¹û¶ÔÏóÊǸÃÀà»ò¸ÃÀàÊǴ˶ÔÏóµÄ¸¸ÀàÔò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ + </para> + <para> + <example> + <title><function>is_a</function> Àý×Ó</title> + <programlisting role="php"> +<![CDATA[ +<?php +// define a class +class WidgetFactory +{ + var $oink = 'moo'; +} + +// create a new object +$WF = new WidgetFactory(); + +if (is_a($WF, 'WidgetFactory')) { + echo "yes, \$WF is still a WidgetFactory\n"; +} +?> +]]> + </programlisting> + </example> + </para> + <para> + <function>is_a</function> º¯ÊýÒÑ·ÏÆú£¬×Ô PHP 5 ÆðÇëʹÓà + <link linkend="language.operators.type">instanceof</link> + ÀàÐÍÔËËã·û¡£ÉÏÀýÔÚ PHP 5 ÖлáÊÇÕâÑù£º + </para> + <para> + <example> + <title>ÔÚ PHP 5 ÖÐʹÓà <emphasis>instanceof</emphasis> ÔËËã·û</title> + <programlisting role="php"> +<![CDATA[ +<?php +if ($WF instanceof WidgetFactory) { + echo 'Yes, $WF is a WidgetFactory'; +} +?> +]]> + </programlisting> + </example> + </para> + <simpara> + ²Î¼û <function>get_class</function>£¬<function>get_parent_class</function> ºÍ + <function>is_subclass_of</function>¡£ + </simpara> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/is-subclass-of.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc-zh/reference/classobj/functions/is-subclass-of.xml diff -u phpdoc-zh/reference/classobj/functions/is-subclass-of.xml:1.1 phpdoc-zh/reference/classobj/functions/is-subclass-of.xml:1.2 --- phpdoc-zh/reference/classobj/functions/is-subclass-of.xml:1.1 Tue Apr 1 13:53:34 2003 +++ phpdoc-zh/reference/classobj/functions/is-subclass-of.xml Fri Jan 20 04:26:35 2006 @@ -1,34 +1,91 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.3 Maintainer: nio Status: ready --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.5 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.4 --> - <refentry id="function.is-subclass-of"> - <refnamediv> - <refname>is_subclass_of</refname> - <refpurpose> - Èç¹û´Ë¶ÔÏóÊǸÃÀàµÄ×ÓÀ࣬Ôò·µ»Ø &true; - </refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>bool</type><methodname>is_subclass_of</methodname> - <methodparam><type>object</type><parameter>object</parameter></methodparam> - <methodparam><type>string</type><parameter>class_name</parameter></methodparam> - </methodsynopsis> - <para> - Èç¹û¶ÔÏó <parameter>object</parameter> - ËùÊôÀàÊÇÀà <parameter>class_name</parameter> - µÄ×ÓÀ࣬Ôò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ - </para> - <simpara> - ²Î¼û <function>get_class</function>¡¢ - <function>get_parent_class</function> ºÍ - <function>is_a</function>¡£ - </simpara> - </refsect1> - </refentry> +<refentry id="function.is-subclass-of"> + <refnamediv> + <refname>is_subclass_of</refname> + <refpurpose>Èç¹û´Ë¶ÔÏóÊǸÃÀàµÄ×ÓÀ࣬Ôò·µ»Ø &true;</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>bool</type><methodname>is_subclass_of</methodname> + <methodparam><type>object</type><parameter>object</parameter></methodparam> + <methodparam><type>string</type><parameter>class_name</parameter></methodparam> + </methodsynopsis> + <para> + Èç¹û¶ÔÏó <parameter>object</parameter> + ËùÊôÀàÊÇÀà <parameter>class_name</parameter> + µÄ×ÓÀ࣬Ôò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ + </para> + <note> + <para> + ×Ô PHP 5.0.3 ÆðÒ²¿ÉÒÔÓÃÒ»¸ö×Ö·û´®À´Ö¸¶¨ <parameter>object</parameter> + ²ÎÊý£¨ÀàÃû£©¡£ + </para> + </note> + <para> + <example> + <title><function>is_subclass_of</function> Àý×Ó</title> + <programlisting role="php"> +<![CDATA[ +<?php +// define a class +class WidgetFactory +{ + var $oink = 'moo'; +} + +// define a child class +class WidgetFactory_Child extends WidgetFactory +{ + var $oink = 'oink'; +} + +// create a new object +$WF = new WidgetFactory(); +$WFC = new WidgetFactory_Child(); + +if (is_subclass_of($WFC, 'WidgetFactory')) { + echo "yes, \$WFC is a subclass of WidgetFactory\n"; +} else { + echo "no, \$WFC is not a subclass of WidgetFactory\n"; +} + +if (is_subclass_of($WF, 'WidgetFactory')) { + echo "yes, \$WF is a subclass of WidgetFactory\n"; +} else { + echo "no, \$WF is not a subclass of WidgetFactory\n"; +} + +// usable only since PHP 5.0.3 +if (is_subclass_of('WidgetFactory_Child', 'WidgetFactory')) { + echo "yes, WidgetFactory_Child is a subclass of WidgetFactory\n"; +} else { + echo "no, WidgetFactory_Child is not a subclass of WidgetFactory\n"; +} +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +yes, $WFC is a subclass of WidgetFactory +no, $WF is not a subclass of WidgetFactory +yes, WidgetFactory_Child is a subclass of WidgetFactory +]]> + </screen> + </example> + </para> + <simpara> + ²Î¼û <function>get_class</function>¡¢ + <function>get_parent_class</function> ºÍ + <function>is_a</function>¡£ + </simpara> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/method-exists.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc-zh/reference/classobj/functions/method-exists.xml diff -u phpdoc-zh/reference/classobj/functions/method-exists.xml:1.1 phpdoc-zh/reference/classobj/functions/method-exists.xml:1.2 --- phpdoc-zh/reference/classobj/functions/method-exists.xml:1.1 Tue Apr 1 14:01:01 2003 +++ phpdoc-zh/reference/classobj/functions/method-exists.xml Fri Jan 20 04:26:35 2006 @@ -1,27 +1,50 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.2 Maintainer: nio Status: ready --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.5 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.9 --> - <refentry id="function.method-exists"> - <refnamediv> - <refname>method_exists</refname> - <refpurpose>¼ì²éÀàµÄ·½·¨ÊÇ·ñ´æÔÚ</refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>bool</type><methodname>method_exists</methodname> - <methodparam><type>object</type><parameter>object</parameter></methodparam> - <methodparam><type>string</type><parameter>method_name</parameter></methodparam> - </methodsynopsis> - <para> - Èç¹û <parameter>method_name</parameter> - ËùÖ¸µÄ·½·¨ÔÚ <parameter>object</parameter> - ËùÖ¸µÄ¶ÔÏóÀàÖÐÒѶ¨Ò壬Ôò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ - </para> - </refsect1> - </refentry> +<refentry id="function.method-exists"> + <refnamediv> + <refname>method_exists</refname> + <refpurpose>¼ì²éÀàµÄ·½·¨ÊÇ·ñ´æÔÚ</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>bool</type><methodname>method_exists</methodname> + <methodparam><type>object</type><parameter>object</parameter></methodparam> + <methodparam><type>string</type><parameter>method_name</parameter></methodparam> + </methodsynopsis> + <para> + Èç¹û <parameter>method_name</parameter> + ËùÖ¸µÄ·½·¨ÔÚ <parameter>object</parameter> + ËùÖ¸µÄ¶ÔÏóÀàÖÐÒѶ¨Ò壬Ôò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ + </para> + <para> + <example> + <title><function>method_exists</function> Àý×Ó</title> + <programlisting role="php"> +<![CDATA[ +<?php +$directory = new Directory('.'); +var_dump(method_exists($directory,'read')); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +bool(true) +]]> + </screen> + </example> + </para> + <para> + ²Î¼û <function>function_exists</function> ºÍ + <function>is_callable</function>¡£ + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables:
http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/get-declared-classes.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc-zh/reference/classobj/functions/get-declared-classes.xml diff -u phpdoc-zh/reference/classobj/functions/get-declared-classes.xml:1.1 phpdoc-zh/reference/classobj/functions/get-declared-classes.xml:1.2 --- phpdoc-zh/reference/classobj/functions/get-declared-classes.xml:1.1 Tue Apr 1 12:46:46 2003 +++ phpdoc-zh/reference/classobj/functions/get-declared-classes.xml Fri Jan 20 04:26:35 2006 @@ -1,41 +1,64 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.3 Maintainer: nio Status: ready --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.6 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.11 --> - <refentry id="function.get-declared-classes"> - <refnamediv> - <refname>get_declared_classes</refname> - <refpurpose>·µ»ØÓÉÒѶ¨ÒåÀàµÄÃû×ÖËù×é³ÉµÄÊý×é</refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>array</type><methodname>get_declared_classes</methodname> - <void/> - </methodsynopsis> - <para> - ·µ»ØÓɵ±Ç°½Å±¾ÖÐÒѶ¨ÒåÀàµÄÃû×Ö×é³ÉµÄÊý×é¡£ - </para> - <note> - <para> - ÔÚ PHP 4.0.1pl2 ÖУ¬ÓÐÈý¸ö¶îÍâµÄÀà´æÔÚÓÚ·µ»ØµÄÊý×éÖУº<classname>stdClass</classname>£¨ÔÚ - <filename>Zend/zend.c</filename> Öж¨Ò壩¡¢<classname>OverloadedTestClass</classname>£¨ÔÚ - <filename>ext/standard/basic_functions.c</filename> Öж¨Ò壩ºÍ - <classname>Directory</classname>£¨ÔÚ<filename> ext/standard/dir.c</filename> Öж¨Ò壩¡£ - </para> - <para> - »¹ÐèҪעÒâµÄÊǶîÍâÀàµÄ³öÏÖÒÀÀµÓÚÄãÒѱàÒëµ½ PHP - ÖеĿ⡣ÕâÒâζ×ÅÄã²»ÄÜʹÓÃÕâЩÀàÃû¶¨Òå×Ô¼ºµÄÀà¡£ÔÚ¸½Â¼µÄ - <link linkend="reserved.classes">Ô¤¶¨ÒåÀà</link> - ²¿·ÖÓÐÔ¤¶¨ÒåÀàµÄÁÐ±í¡£ - </para> - </note> - <simpara> - ²Î¼û <function>class_exists</function>¡£ - </simpara> - </refsect1> - </refentry> +<refentry id="function.get-declared-classes"> + <refnamediv> + <refname>get_declared_classes</refname> + <refpurpose>·µ»ØÓÉÒѶ¨ÒåÀàµÄÃû×ÖËù×é³ÉµÄÊý×é</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>array</type><methodname>get_declared_classes</methodname> + <void/> + </methodsynopsis> + <para> + ·µ»ØÓɵ±Ç°½Å±¾ÖÐÒѶ¨ÒåÀàµÄÃû×Ö×é³ÉµÄÊý×é¡£ + </para> + <note> + <para> + ÔÚ PHP 4.0.1pl2 ÖУ¬ÓÐÈý¸ö¶îÍâµÄÀà´æÔÚÓÚ·µ»ØµÄÊý×éÖУº<classname>stdClass</classname>£¨ÔÚ + <filename>Zend/zend.c</filename> Öж¨Ò壩¡¢<classname>OverloadedTestClass</classname>£¨ÔÚ + <filename>ext/standard/basic_functions.c</filename> Öж¨Ò壩ºÍ + <classname>Directory</classname>£¨ÔÚ<filename> ext/standard/dir.c</filename> Öж¨Ò壩¡£ + </para> + <para> + »¹ÐèҪעÒâµÄÊǶîÍâÀàµÄ³öÏÖÒÀÀµÓÚÄãÒѱàÒëµ½ PHP + ÖеĿ⡣ÕâÒâζ×ÅÄã²»ÄÜʹÓÃÕâЩÀàÃû¶¨Òå×Ô¼ºµÄÀà¡£ÔÚ¸½Â¼µÄ + <link linkend="reserved.classes">Ô¤¶¨ÒåÀà</link> + ²¿·ÖÓÐÔ¤¶¨ÒåÀàµÄÁÐ±í¡£ + </para> + </note> + <para> + <example> + <title><function>get_declared_classes</function> Àý×Ó</title> + <programlisting role="php"> +<![CDATA[ +<?php +print_r(get_declared_classes()); +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +Array +( + [0] => stdClass + [1] => __PHP_Incomplete_Class + [2] => Directory +) +]]> + </screen> + </example> + </para> + <simpara> + ²Î¼û <function>class_exists</function> ºÍ <function>get_declared_interfaces</function>¡£ + </simpara> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/get-object-vars.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc-zh/reference/classobj/functions/get-object-vars.xml diff -u phpdoc-zh/reference/classobj/functions/get-object-vars.xml:1.1 phpdoc-zh/reference/classobj/functions/get-object-vars.xml:1.2 --- phpdoc-zh/reference/classobj/functions/get-object-vars.xml:1.1 Tue Apr 1 13:09:24 2003 +++ phpdoc-zh/reference/classobj/functions/get-object-vars.xml Fri Jan 20 04:26:35 2006 @@ -1,51 +1,53 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.3 Maintainer: nio Status: ready --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.8 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.1 --> - <refentry id="function.get-object-vars"> - <refnamediv> - <refname>get_object_vars</refname> - <refpurpose>·µ»ØÓɶÔÏóÊôÐÔ×é³ÉµÄ¹ØÁªÊý×é</refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>array</type><methodname>get_object_vars</methodname> - <methodparam><type>object</type><parameter>obj</parameter></methodparam> - </methodsynopsis> - <para> - ·µ»ØÓÉ <parameter>obj</parameter> - Ö¸¶¨µÄ¶ÔÏóÖж¨ÒåµÄÊôÐÔ×é³ÉµÄ¹ØÁªÊý×é¡£ - </para> - <note> - <para> - ÔÚ PHP 4.2.0 ֮ǰµÄ°æ±¾ÖУ¬Èç¹ûÔÚ <parameter>obj</parameter> - ¶ÔÏóʵÀýÖÐÉùÃ÷µÄ±äÁ¿Ã»Óб»¸³Öµ£¬ÔòËüÃǽ«²»»áÔÚ·µ»ØµÄÊý×éÖС£¶øÔÚ - PHP 4.2.0 Ö®ºó£¬ÕâЩ±äÁ¿×÷Ϊ¼üÃû½«±»¸³Óè <constant>NULL</constant> - Öµ¡£ - </para> - </note> - <para> - <example> - <title>ʹÓà <function>get_object_vars</function></title> - <programlisting role="php"> +<refentry id="function.get-object-vars"> + <refnamediv> + <refname>get_object_vars</refname> + <refpurpose>·µ»ØÓɶÔÏóÊôÐÔ×é³ÉµÄ¹ØÁªÊý×é</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>array</type><methodname>get_object_vars</methodname> + <methodparam><type>object</type><parameter>obj</parameter></methodparam> + </methodsynopsis> + <para> + ·µ»ØÓÉ <parameter>obj</parameter> + Ö¸¶¨µÄ¶ÔÏóÖж¨ÒåµÄÊôÐÔ×é³ÉµÄ¹ØÁªÊý×é¡£ + </para> + <note> + <para> + ÔÚ PHP 4.2.0 ֮ǰµÄ°æ±¾ÖУ¬Èç¹ûÔÚ <parameter>obj</parameter> + ¶ÔÏóʵÀýÖÐÉùÃ÷µÄ±äÁ¿Ã»Óб»¸³Öµ£¬ÔòËüÃǽ«²»»áÔÚ·µ»ØµÄÊý×éÖС£¶øÔÚ + PHP 4.2.0 Ö®ºó£¬ÕâЩ±äÁ¿×÷Ϊ¼üÃû½«±»¸³Óè &null; Öµ¡£ + </para> + </note> + <para> + <example> + <title>ʹÓà <function>get_object_vars</function></title> + <programlisting role="php"> <![CDATA[ <?php class Point2D { var $x, $y; var $label; - function Point2D($x, $y) { + function Point2D($x, $y) + { $this->x = $x; $this->y = $y; } - function setLabel($label) { + function setLabel($label) + { $this->label = $label; } - function getPoint() { + function getPoint() + { return array("x" => $this->x, "y" => $this->y, "label" => $this->label); @@ -61,10 +63,9 @@ ?> ]]> - </programlisting> - </example> - ÉϱߵijÌÐò½«Êä³ö£º - <screen> + </programlisting> + &example.outputs; + <screen> <![CDATA[ Array ( @@ -80,14 +81,15 @@ [label] => point #1 ) ]]> - </screen> - </para> - <simpara> - ²Î¼û <function>get_class_methods</function> ºÍ - <function>get_class_vars</function>£¡ - </simpara> - </refsect1> - </refentry> + </screen> + </example> + </para> + <simpara> + ²Î¼û <function>get_class_methods</function> ºÍ + <function>get_class_vars</function>¡£ + </simpara> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/get-parent-class.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc-zh/reference/classobj/functions/get-parent-class.xml diff -u phpdoc-zh/reference/classobj/functions/get-parent-class.xml:1.1 phpdoc-zh/reference/classobj/functions/get-parent-class.xml:1.2 --- phpdoc-zh/reference/classobj/functions/get-parent-class.xml:1.1 Tue Apr 1 13:17:25 2003 +++ phpdoc-zh/reference/classobj/functions/get-parent-class.xml Fri Jan 20 04:26:35 2006 @@ -1,35 +1,83 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.2 Maintainer: nio Status: ready --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.7 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.4 --> - <refentry id="function.get-parent-class"> - <refnamediv> - <refname>get_parent_class</refname> - <refpurpose>·µ»Ø¶ÔÏó»òÀàµÄ¸¸ÀàÃû</refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>string</type><methodname>get_parent_class</methodname> - <methodparam><type>mixed</type><parameter>obj</parameter></methodparam> - </methodsynopsis> - <para> - Èç¹û <parameter>obj</parameter> - ÊǶÔÏó£¬Ôò·µ»Ø¶ÔÏóʵÀý <parameter>obj</parameter> - ËùÊôÀàµÄ¸¸ÀàÃû¡£ - </para> - <para> - Èç¹û <parameter>obj</parameter> - ÊÇ×Ö·û´®£¬Ôò·µ»ØÒÔ´Ë×Ö·û´®ÎªÃûµÄÀàµÄ¸¸ÀàÃû¡£´Ë¹¦ÄÜÊÇÔÚ - PHP 4.0.5 ÖÐÔö¼ÓµÄ¡£ - </para> - <simpara> - ²Î¼û <function>get_class</function> ºÍ - <function>is_subclass_of</function> - </simpara> - </refsect1> - </refentry> +<refentry id="function.get-parent-class"> + <refnamediv> + <refname>get_parent_class</refname> + <refpurpose>·µ»Ø¶ÔÏó»òÀàµÄ¸¸ÀàÃû</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>string</type><methodname>get_parent_class</methodname> + <methodparam choice="opt"><type>mixed</type><parameter>obj</parameter></methodparam> + </methodsynopsis> + <para> + Èç¹û <parameter>obj</parameter> + ÊǶÔÏó£¬Ôò·µ»Ø¶ÔÏóʵÀý <parameter>obj</parameter> + ËùÊôÀàµÄ¸¸ÀàÃû¡£ + </para> + <para> + Èç¹û <parameter>obj</parameter> + ÊÇ×Ö·û´®£¬Ôò·µ»ØÒÔ´Ë×Ö·û´®ÎªÃûµÄÀàµÄ¸¸ÀàÃû¡£´Ë¹¦ÄÜÊÇÔÚ + PHP 4.0.5 ÖÐÔö¼ÓµÄ¡£ + </para> + <note> + <para> + ×Ô PHP 5 Æð£¬Èç¹ûÔÚ¶ÔÏóµÄ·½·¨ÄÚµ÷Óã¬Ôò <parameter>obj</parameter> Ϊ¿ÉÑ¡Ïî¡£ + </para> + </note> + <para> + <example> + <title>ʹÓà <function>get_parent_class</function></title> + <programlisting role="php"> +<![CDATA[ +<?php + +class dad { + function dad() + { + // implements some logic + } +} + +class child extends dad { + function child() + { + echo "I'm " , get_parent_class($this) , "'s son\n"; + } +} + +class child2 extends dad { + function child2() + { + echo "I'm " , get_parent_class('child2') , "'s son too\n"; + } +} + +$foo = new child(); +$bar = new child2(); + +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +I'm dad's son +I'm dad's son too +]]> + </screen> + </example> + </para> + <para> + ²Î¼û <function>get_class</function> ºÍ + <function>is_subclass_of</function>¡£ + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/is-a.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc-zh/reference/classobj/functions/is-a.xml diff -u phpdoc-zh/reference/classobj/functions/is-a.xml:1.2 phpdoc-zh/reference/classobj/functions/is-a.xml:1.3 --- phpdoc-zh/reference/classobj/functions/is-a.xml:1.2 Tue Apr 1 13:51:18 2003 +++ phpdoc-zh/reference/classobj/functions/is-a.xml Fri Jan 20 04:26:35 2006 @@ -1,32 +1,71 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.2 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.3 Maintainer: nio Status: ready --> +<!-- $Revision: 1.3 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.7 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.33 --> - <refentry id="function.is-a"> - <refnamediv> - <refname>is_a</refname> - <refpurpose> - Èç¹û¶ÔÏóÊôÓÚ¸ÃÀà»ò¸ÃÀàÊǴ˶ÔÏóµÄ¸¸ÀàÔò·µ»Ø &true; - </refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>bool</type><methodname>is_a</methodname> - <methodparam><type>object</type><parameter>object</parameter></methodparam> - <methodparam><type>string</type><parameter>class_name</parameter></methodparam> - </methodsynopsis> - <para> - Èç¹û¶ÔÏóÊǸÃÀà»ò¸ÃÀàÊǴ˶ÔÏóµÄ¸¸ÀàÔò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ - </para> - <simpara> - ²Î¼û <function>get_class</function>¡¢ - <function>get_parent_class</function> ºÍ - <function>is_subclass_of</function>¡£ - </simpara> - </refsect1> - </refentry> +<refentry id="function.is-a"> + <refnamediv> + <refname>is_a</refname> + <refpurpose>Èç¹û¶ÔÏóÊôÓÚ¸ÃÀà»ò¸ÃÀàÊǴ˶ÔÏóµÄ¸¸ÀàÔò·µ»Ø &true;</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>bool</type><methodname>is_a</methodname> + <methodparam><type>object</type><parameter>object</parameter></methodparam> + <methodparam><type>string</type><parameter>class_name</parameter></methodparam> + </methodsynopsis> + <para> + Èç¹û¶ÔÏóÊǸÃÀà»ò¸ÃÀàÊǴ˶ÔÏóµÄ¸¸ÀàÔò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ + </para> + <para> + <example> + <title><function>is_a</function> Àý×Ó</title> + <programlisting role="php"> +<![CDATA[ +<?php +// define a class +class WidgetFactory +{ + var $oink = 'moo'; +} + +// create a new object +$WF = new WidgetFactory(); + +if (is_a($WF, 'WidgetFactory')) { + echo "yes, \$WF is still a WidgetFactory\n"; +} +?> +]]> + </programlisting> + </example> + </para> + <para> + <function>is_a</function> º¯ÊýÒÑ·ÏÆú£¬×Ô PHP 5 ÆðÇëʹÓà + <link linkend="language.operators.type">instanceof</link> + ÀàÐÍÔËËã·û¡£ÉÏÀýÔÚ PHP 5 ÖлáÊÇÕâÑù£º + </para> + <para> + <example> + <title>ÔÚ PHP 5 ÖÐʹÓà <emphasis>instanceof</emphasis> ÔËËã·û</title> + <programlisting role="php"> +<![CDATA[ +<?php +if ($WF instanceof WidgetFactory) { + echo 'Yes, $WF is a WidgetFactory'; +} +?> +]]> + </programlisting> + </example> + </para> + <simpara> + ²Î¼û <function>get_class</function>£¬<function>get_parent_class</function> ºÍ + <function>is_subclass_of</function>¡£ + </simpara> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/is-subclass-of.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc-zh/reference/classobj/functions/is-subclass-of.xml diff -u phpdoc-zh/reference/classobj/functions/is-subclass-of.xml:1.1 phpdoc-zh/reference/classobj/functions/is-subclass-of.xml:1.2 --- phpdoc-zh/reference/classobj/functions/is-subclass-of.xml:1.1 Tue Apr 1 13:53:34 2003 +++ phpdoc-zh/reference/classobj/functions/is-subclass-of.xml Fri Jan 20 04:26:35 2006 @@ -1,34 +1,91 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.3 Maintainer: nio Status: ready --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.5 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.4 --> - <refentry id="function.is-subclass-of"> - <refnamediv> - <refname>is_subclass_of</refname> - <refpurpose> - Èç¹û´Ë¶ÔÏóÊǸÃÀàµÄ×ÓÀ࣬Ôò·µ»Ø &true; - </refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>bool</type><methodname>is_subclass_of</methodname> - <methodparam><type>object</type><parameter>object</parameter></methodparam> - <methodparam><type>string</type><parameter>class_name</parameter></methodparam> - </methodsynopsis> - <para> - Èç¹û¶ÔÏó <parameter>object</parameter> - ËùÊôÀàÊÇÀà <parameter>class_name</parameter> - µÄ×ÓÀ࣬Ôò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ - </para> - <simpara> - ²Î¼û <function>get_class</function>¡¢ - <function>get_parent_class</function> ºÍ - <function>is_a</function>¡£ - </simpara> - </refsect1> - </refentry> +<refentry id="function.is-subclass-of"> + <refnamediv> + <refname>is_subclass_of</refname> + <refpurpose>Èç¹û´Ë¶ÔÏóÊǸÃÀàµÄ×ÓÀ࣬Ôò·µ»Ø &true;</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>bool</type><methodname>is_subclass_of</methodname> + <methodparam><type>object</type><parameter>object</parameter></methodparam> + <methodparam><type>string</type><parameter>class_name</parameter></methodparam> + </methodsynopsis> + <para> + Èç¹û¶ÔÏó <parameter>object</parameter> + ËùÊôÀàÊÇÀà <parameter>class_name</parameter> + µÄ×ÓÀ࣬Ôò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ + </para> + <note> + <para> + ×Ô PHP 5.0.3 ÆðÒ²¿ÉÒÔÓÃÒ»¸ö×Ö·û´®À´Ö¸¶¨ <parameter>object</parameter> + ²ÎÊý£¨ÀàÃû£©¡£ + </para> + </note> + <para> + <example> + <title><function>is_subclass_of</function> Àý×Ó</title> + <programlisting role="php"> +<![CDATA[ +<?php +// define a class +class WidgetFactory +{ + var $oink = 'moo'; +} + +// define a child class +class WidgetFactory_Child extends WidgetFactory +{ + var $oink = 'oink'; +} + +// create a new object +$WF = new WidgetFactory(); +$WFC = new WidgetFactory_Child(); + +if (is_subclass_of($WFC, 'WidgetFactory')) { + echo "yes, \$WFC is a subclass of WidgetFactory\n"; +} else { + echo "no, \$WFC is not a subclass of WidgetFactory\n"; +} + +if (is_subclass_of($WF, 'WidgetFactory')) { + echo "yes, \$WF is a subclass of WidgetFactory\n"; +} else { + echo "no, \$WF is not a subclass of WidgetFactory\n"; +} + +// usable only since PHP 5.0.3 +if (is_subclass_of('WidgetFactory_Child', 'WidgetFactory')) { + echo "yes, WidgetFactory_Child is a subclass of WidgetFactory\n"; +} else { + echo "no, WidgetFactory_Child is not a subclass of WidgetFactory\n"; +} +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +yes, $WFC is a subclass of WidgetFactory +no, $WF is not a subclass of WidgetFactory +yes, WidgetFactory_Child is a subclass of WidgetFactory +]]> + </screen> + </example> + </para> + <simpara> + ²Î¼û <function>get_class</function>¡¢ + <function>get_parent_class</function> ºÍ + <function>is_a</function>¡£ + </simpara> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewcvs.cgi/phpdoc-zh/reference/classobj/functions/method-exists.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc-zh/reference/classobj/functions/method-exists.xml diff -u phpdoc-zh/reference/classobj/functions/method-exists.xml:1.1 phpdoc-zh/reference/classobj/functions/method-exists.xml:1.2 --- phpdoc-zh/reference/classobj/functions/method-exists.xml:1.1 Tue Apr 1 14:01:01 2003 +++ phpdoc-zh/reference/classobj/functions/method-exists.xml Fri Jan 20 04:26:35 2006 @@ -1,27 +1,50 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> -<!-- $Author: nio $ --> -<!-- EN-Revision: 1.2 Maintainer: nio Status: ready --> +<!-- $Revision: 1.2 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.5 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.9 --> - <refentry id="function.method-exists"> - <refnamediv> - <refname>method_exists</refname> - <refpurpose>¼ì²éÀàµÄ·½·¨ÊÇ·ñ´æÔÚ</refpurpose> - </refnamediv> - <refsect1> - <title>ÃèÊö</title> - <methodsynopsis> - <type>bool</type><methodname>method_exists</methodname> - <methodparam><type>object</type><parameter>object</parameter></methodparam> - <methodparam><type>string</type><parameter>method_name</parameter></methodparam> - </methodsynopsis> - <para> - Èç¹û <parameter>method_name</parameter> - ËùÖ¸µÄ·½·¨ÔÚ <parameter>object</parameter> - ËùÖ¸µÄ¶ÔÏóÀàÖÐÒѶ¨Ò壬Ôò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ - </para> - </refsect1> - </refentry> +<refentry id="function.method-exists"> + <refnamediv> + <refname>method_exists</refname> + <refpurpose>¼ì²éÀàµÄ·½·¨ÊÇ·ñ´æÔÚ</refpurpose> + </refnamediv> + <refsect1> + <title>˵Ã÷</title> + <methodsynopsis> + <type>bool</type><methodname>method_exists</methodname> + <methodparam><type>object</type><parameter>object</parameter></methodparam> + <methodparam><type>string</type><parameter>method_name</parameter></methodparam> + </methodsynopsis> + <para> + Èç¹û <parameter>method_name</parameter> + ËùÖ¸µÄ·½·¨ÔÚ <parameter>object</parameter> + ËùÖ¸µÄ¶ÔÏóÀàÖÐÒѶ¨Ò壬Ôò·µ»Ø &true;£¬·ñÔò·µ»Ø &false;¡£ + </para> + <para> + <example> + <title><function>method_exists</function> Àý×Ó</title> + <programlisting role="php"> +<![CDATA[ +<?php +$directory = new Directory('.'); +var_dump(method_exists($directory,'read')); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +bool(true) +]]> + </screen> + </example> + </para> + <para> + ²Î¼û <function>function_exists</function> ºÍ + <function>is_callable</function>¡£ + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: