mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-04-28 11:13:14 +02:00
18cfe4de53
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@171872 c90b9560-bf6c-de11-be94-00142212c4b1
94 lines
2.5 KiB
XML
94 lines
2.5 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.7 $ -->
|
|
<!-- EN-Revision: 1.7 Maintainer: dams Status: ready -->
|
|
<refentry id="function.is-a">
|
|
<refnamediv>
|
|
<refname>is_a</refname>
|
|
<refpurpose>
|
|
Retourne &true; si un objet a pour parent une classe donnée
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
&reftitle.description;
|
|
<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>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>is_a</function> retourne &true; si l'objet <parameter>object</parameter>
|
|
a pour classe <parameter>class_name</parameter>, ou bien si <parameter>class_name</parameter>
|
|
est un de ses parents. <function>is_a</function> retourne &false; sinon.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>is_a</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Définit une classe
|
|
class WidgetFactory
|
|
{
|
|
var $oink = 'moo';
|
|
}
|
|
|
|
// Crée un nouvel objet
|
|
$WF = new WidgetFactory();
|
|
|
|
if (is_a($WF, 'WidgetFactory')) {
|
|
echo "oui, \$WF est toujours un objet WidgetFactory\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
La fonction <function>is_a</function> est déconseillé en &php; 5 en faveur de
|
|
l'opérateur de type <link linkend="language.operators.type">instanceof</link>.
|
|
Voir un exemple de cette utilisation avec &php; 5 :
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Utilisation de l'opérateur <emphasis>instanceof</emphasis> avec &php; 5</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
if ($WF instanceof WidgetFactory) {
|
|
echo 'Oui, $WF est un WidgetFactory';
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<simpara>
|
|
Voir aussi
|
|
<function>get_class</function>,
|
|
<function>get_parent_class</function> et
|
|
<function>is_subclass_of</function>.
|
|
</simpara>
|
|
</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
|
|
-->
|