2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2007-01-14 13:37:31 +00:00
|
|
|
<!-- $Revision: 1.6 $ -->
|
|
|
|
<refentry id="function.is-subclass-of">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>is_subclass_of</refname>
|
|
|
|
<refpurpose>Returns &true; if the object has this class as one of its parents</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>bool</type><methodname>is_subclass_of</methodname>
|
|
|
|
<methodparam><type>mixed</type><parameter>object</parameter></methodparam>
|
|
|
|
<methodparam><type>string</type><parameter>class_name</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
This function returns &true; if the object
|
|
|
|
<parameter>object</parameter>, belongs to a class which is a
|
|
|
|
subclass of <parameter>class_name</parameter>, &false; otherwise.
|
|
|
|
</para>
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
Since PHP 5.0.3 you may also specify the <parameter>object</parameter>
|
|
|
|
parameter as a string (the name of the class).
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>is_subclass_of</function> example</title>
|
|
|
|
<programlisting role="php">
|
2004-07-23 18:15:29 +00:00
|
|
|
<![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";
|
|
|
|
}
|
2004-10-27 14:38:25 +00:00
|
|
|
|
2004-07-23 18:15:29 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
}
|
2004-10-27 14:38:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
// 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";
|
|
|
|
}
|
2004-07-23 18:15:29 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2007-01-14 13:37:31 +00:00
|
|
|
</programlisting>
|
|
|
|
&example.outputs;
|
|
|
|
<screen>
|
2004-10-27 14:38:25 +00:00
|
|
|
<![CDATA[
|
|
|
|
yes, $WFC is a subclass of WidgetFactory
|
|
|
|
no, $WF is not a subclass of WidgetFactory
|
|
|
|
yes, WidgetFactory_Child is a subclass of WidgetFactory
|
|
|
|
]]>
|
2007-01-14 13:37:31 +00:00
|
|
|
</screen>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<simpara>
|
|
|
|
See also <function>get_class</function>,
|
|
|
|
<function>get_parent_class</function> and
|
|
|
|
<function>is_a</function>.
|
|
|
|
</simpara>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- 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
|
|
|
|
-->
|