2014-09-05 07:44:07 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 08:59:47 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.class-parents" xmlns="http://docbook.org/ns/docbook">
|
2005-04-11 15:11:38 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>class_parents</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Return the parent classes of the given class
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
2005-04-11 15:21:21 +00:00
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2005-04-11 15:11:38 +00:00
|
|
|
<methodsynopsis>
|
2021-08-11 21:44:41 +00:00
|
|
|
<type class="union"><type>array</type><type>false</type></type><methodname>class_parents</methodname>
|
|
|
|
<methodparam><type class="union"><type>object</type><type>string</type></type><parameter>object_or_class</parameter></methodparam>
|
2018-01-25 19:11:34 +00:00
|
|
|
<methodparam choice="opt"><type>bool</type><parameter>autoload</parameter><initializer>&true;</initializer></methodparam>
|
2005-04-11 15:11:38 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
This function returns an array with the name of the parent classes of
|
2021-08-11 21:44:41 +00:00
|
|
|
the given <parameter>object_or_class</parameter>.
|
2005-04-11 15:11:38 +00:00
|
|
|
</para>
|
2005-04-11 15:21:21 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2021-08-11 21:44:41 +00:00
|
|
|
<term><parameter>object_or_class</parameter></term>
|
2005-04-11 15:21:21 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-08-01 22:29:40 +00:00
|
|
|
An object (class instance) or a string (class name).
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>autoload</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2021-07-11 16:00:43 +00:00
|
|
|
Whether to call &link.autoload; by default.
|
2005-04-11 15:21:21 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
2021-08-11 21:44:41 +00:00
|
|
|
An array on success, or &false; when the given class doesn't exist.
|
2005-04-11 15:21:21 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
2005-04-11 15:11:38 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>class_parents</function> example</title>
|
|
|
|
<programlisting role="php">
|
2004-10-08 18:37:05 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
|
|
|
class foo { }
|
|
|
|
class bar extends foo {}
|
|
|
|
|
|
|
|
print_r(class_parents(new bar));
|
|
|
|
|
2021-04-23 08:35:26 +00:00
|
|
|
// you may also specify the parameter as a string
|
2005-08-01 22:29:40 +00:00
|
|
|
print_r(class_parents('bar'));
|
|
|
|
|
2021-07-11 16:00:43 +00:00
|
|
|
spl_autoload_register();
|
2005-08-01 22:29:40 +00:00
|
|
|
|
2021-07-11 16:00:43 +00:00
|
|
|
// use autoloading to load the 'not_loaded' class
|
2005-08-04 10:59:37 +00:00
|
|
|
print_r(class_parents('not_loaded', true));
|
2021-07-11 16:00:43 +00:00
|
|
|
|
2004-10-08 18:37:05 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2005-04-11 15:11:38 +00:00
|
|
|
</programlisting>
|
2005-08-04 10:59:37 +00:00
|
|
|
&example.outputs.similar;
|
2005-04-11 15:11:38 +00:00
|
|
|
<screen>
|
2004-10-08 18:37:05 +00:00
|
|
|
<![CDATA[
|
|
|
|
Array
|
|
|
|
(
|
|
|
|
[foo] => foo
|
|
|
|
)
|
2021-07-11 16:00:43 +00:00
|
|
|
Array
|
|
|
|
(
|
|
|
|
[foo] => foo
|
|
|
|
)
|
2005-08-04 10:59:37 +00:00
|
|
|
Array
|
|
|
|
(
|
2005-08-04 11:02:17 +00:00
|
|
|
[parent_of_not_loaded] => parent_of_not_loaded
|
2005-08-04 10:59:37 +00:00
|
|
|
)
|
2004-10-08 18:37:05 +00:00
|
|
|
]]>
|
2005-04-11 15:11:38 +00:00
|
|
|
</screen>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2005-04-11 15:21:21 +00:00
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
|
|
|
<para>
|
|
|
|
<simplelist>
|
|
|
|
<member><function>class_implements</function></member>
|
|
|
|
</simplelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2005-04-11 15:11:38 +00:00
|
|
|
</refentry>
|
2004-10-08 18:37:05 +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
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2004-10-08 18:37:05 +00:00
|
|
|
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
|
|
|
|
-->
|