mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 18:38:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@297028 c90b9560-bf6c-de11-be94-00142212c4b1
170 lines
4 KiB
XML
170 lines
4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="function.is-subclass-of" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>is_subclass_of</refname>
|
|
<refpurpose>Checks if the object has this class as one of its parents</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<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>
|
|
Checks if the given <parameter>object</parameter> has the class
|
|
<parameter>class_name</parameter> as one of its parents.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>object</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
A class name or an object instance
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>class_name</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The class name
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<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>
|
|
</refsect1>
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.0.3</entry>
|
|
<entry>
|
|
You may also specify the <parameter>object</parameter> parameter as a
|
|
string (the name of the class)
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<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";
|
|
}
|
|
|
|
|
|
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>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.uses-autoload;
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>get_class</function></member>
|
|
<member><function>get_parent_class</function></member>
|
|
<member><function>is_a</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</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:"~/.phpdoc/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
|
|
-->
|