mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-22 03:48:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@164117 c90b9560-bf6c-de11-be94-00142212c4b1
90 lines
2.4 KiB
XML
90 lines
2.4 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.4 $ -->
|
|
<!-- 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>
|
|
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>object</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>
|
|
<para>
|
|
<example>
|
|
<title><function>is_subclass_of</function> example</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";
|
|
}
|
|
// Outputs "yes, $WFC is 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";
|
|
}
|
|
// Outputs "no, $WF is not a subclass of WidgetFactory\n"
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<simpara>
|
|
See also <function>get_class</function>,
|
|
<function>get_parent_class</function> and
|
|
<function>is_a</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- 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
|
|
-->
|