php-doc-en/reference/classobj/functions/get-parent-class.xml
2006-03-07 08:32:44 +00:00

102 lines
2.5 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- 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>Retrieves the parent class name for object or class</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>get_parent_class</methodname>
<methodparam choice="opt"><type>mixed</type><parameter>obj</parameter></methodparam>
</methodsynopsis>
<para>
If <parameter>obj</parameter> is an object, returns the name of the
parent class of the class of which <parameter>obj</parameter> is an
instance.
</para>
<para>
If <parameter>obj</parameter> is a string, returns the name of the parent
class of the class with that name. This functionality was added in PHP
4.0.5.
</para>
<note>
<para>
Since PHP 5, <parameter>obj</parameter> is optional if called from the
object's method.
If called without parameter outside object, this function returns
&false; (or &null; with a warning before PHP 5.1.0).
</para>
</note>
<para>
<example>
<title>Using <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>
See also <function>get_class</function> and
<function>is_subclass_of</function>.
</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:"../../../../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
-->