kennyt Fri Mar 5 16:24:41 2004 EDT
Modified files: /phpdoc/en/language operators.xml Log: Added 'instanceof' as a 'type operator.' http://cvs.php.net/diff.php/phpdoc/en/language/operators.xml?r1=1.61&r2=1.62&ty=u Index: phpdoc/en/language/operators.xml diff -u phpdoc/en/language/operators.xml:1.61 phpdoc/en/language/operators.xml:1.62 --- phpdoc/en/language/operators.xml:1.61 Sat Jan 31 06:45:33 2004 +++ phpdoc/en/language/operators.xml Fri Mar 5 16:24:40 2004 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.61 $ --> +<!-- $Revision: 1.62 $ --> <chapter id="language.operators"> <title>Operators</title> <simpara> @@ -875,6 +875,41 @@ <link linkend="ref.array">Array functions</link>. </para> </sect1> + <sect1 id="language.operators.type"> + <title>Type Operators</title> + <para> + PHP has a single type operator: <literal>instanceof</literal>. + <literal>instanceof</literal> is used to determine whether a given + object is of a specified <link linkend="language.oop">object class</link>. + </para> + <simpara> + <literal>instanceof</literal> was introduced in PHP version 5. + </simpara> + <informalexample> + <programlisting> +<![CDATA[ +<?php +class A { } +class B { } + +$thing = new A; + +if ($thing instanceof A) { + echo 'A'; +} +if ($thing instanceof B) { + echo 'B'; +} +?> +]]> + </programlisting> + <simpara> + As <literal>$thing</literal> is an object of type A, but not B, only the block + dependent on the A type will be executed: + </simpara> + <screen>A</screen> + </informalexample> + </sect1> </chapter> <!-- Keep this comment at the end of the file