<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.3 $ --> <!-- 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><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> <para> <example> <title>Using <function>get_parent_class</function></title> <programlisting> <![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> <para> The output is: </para> <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 -->