2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 06:41:36 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.is-a" xmlns="http://docbook.org/ns/docbook">
|
2007-01-14 13:37:31 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>is_a</refname>
|
2007-01-14 15:10:19 +00:00
|
|
|
<refpurpose>Checks if the object is of this class or has this class as one of its parents</refpurpose>
|
2007-01-14 13:37:31 +00:00
|
|
|
</refnamediv>
|
2007-01-14 15:10:19 +00:00
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2007-01-14 13:37:31 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>bool</type><methodname>is_a</methodname>
|
|
|
|
<methodparam><type>object</type><parameter>object</parameter></methodparam>
|
|
|
|
<methodparam><type>string</type><parameter>class_name</parameter></methodparam>
|
2012-01-11 04:05:57 +00:00
|
|
|
<methodparam choice="opt"><type>bool</type><parameter>allow_string</parameter><initializer>&false;</initializer></methodparam>
|
2007-01-14 13:37:31 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
2007-01-14 15:10:19 +00:00
|
|
|
Checks if the given <parameter>object</parameter> is of this class or has
|
|
|
|
this class as one of its parents.
|
2007-01-14 13:37:31 +00:00
|
|
|
</para>
|
2007-01-14 15:10:19 +00:00
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>object</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The tested object
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>class_name</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The class name
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2012-01-11 04:05:57 +00:00
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>allow_string</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2012-12-08 00:03:37 +00:00
|
|
|
If this parameter set to &false;, string class name as <parameter>object</parameter>
|
2012-03-31 09:48:19 +00:00
|
|
|
is not allowed. This also prevents from calling autoloader if the class doesn't exist.
|
2012-01-11 04:05:57 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2007-01-14 15:10:19 +00:00
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
|
|
|
Returns &true; if the object is of this class or has this class as one of
|
|
|
|
its parents, &false; otherwise.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2008-12-10 01:46:03 +00:00
|
|
|
<refsect1 role="changelog">
|
|
|
|
&reftitle.changelog;
|
|
|
|
<para>
|
|
|
|
<informaltable>
|
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>&Version;</entry>
|
|
|
|
<entry>&Description;</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2012-01-11 04:05:57 +00:00
|
|
|
<row>
|
|
|
|
<entry>5.3.9</entry>
|
|
|
|
<entry>
|
|
|
|
Added <parameter>allow_string</parameter> parameter
|
|
|
|
</entry>
|
|
|
|
</row>
|
2008-12-10 01:46:03 +00:00
|
|
|
<row>
|
|
|
|
<entry>5.3.0</entry>
|
|
|
|
<entry>
|
|
|
|
This function is no longer deprecated, and will therefore
|
2008-12-11 14:41:08 +00:00
|
|
|
no longer throw <constant>E_STRICT</constant> warnings.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>5.0.0</entry>
|
|
|
|
<entry>
|
|
|
|
This function became deprecated in favour of the
|
|
|
|
<link linkend="language.operators.type">instanceof</link>
|
|
|
|
operator. Calling this function will result in an
|
|
|
|
<constant>E_STRICT</constant> warning.
|
2008-12-10 01:46:03 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</informaltable>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-01-14 15:10:19 +00:00
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
2007-01-14 13:37:31 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>is_a</function> example</title>
|
|
|
|
<programlisting role="php">
|
2004-02-24 05:54:36 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
// define a class
|
|
|
|
class WidgetFactory
|
|
|
|
{
|
|
|
|
var $oink = 'moo';
|
|
|
|
}
|
|
|
|
|
|
|
|
// create a new object
|
|
|
|
$WF = new WidgetFactory();
|
|
|
|
|
2004-02-24 08:42:32 +00:00
|
|
|
if (is_a($WF, 'WidgetFactory')) {
|
2004-02-24 16:28:22 +00:00
|
|
|
echo "yes, \$WF is still a WidgetFactory\n";
|
2004-02-24 05:54:36 +00:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
]]>
|
2007-01-14 13:37:31 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
<example>
|
|
|
|
<title>Using the <emphasis>instanceof</emphasis> operator in PHP 5</title>
|
|
|
|
<programlisting role="php">
|
2004-05-24 21:53:23 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
if ($WF instanceof WidgetFactory) {
|
|
|
|
echo 'Yes, $WF is a WidgetFactory';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
]]>
|
2007-01-14 13:37:31 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
2007-01-14 15:10:19 +00:00
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
|
|
|
<para>
|
|
|
|
<simplelist>
|
|
|
|
<member><function>get_class</function></member>
|
|
|
|
<member><function>get_parent_class</function></member>
|
|
|
|
<member><function>is_subclass_of</function></member>
|
|
|
|
</simplelist>
|
|
|
|
</para>
|
2007-01-14 13:37:31 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2002-04-15 00:12:54 +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"
|
2002-04-15 00:12:54 +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
|
|
|
|
-->
|