Files
php-doc-ru/reference/classobj/functions/is-a.xml
2022-12-24 11:48:55 +03:00

131 lines
4.0 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 944af3a79d0bb9520839a08414924e997a0dc01e Maintainer: shein Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.is-a" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>is_a</refname>
<refpurpose>Проверяет, является ли объект указанным типом или подтипом</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>is_a</methodname>
<methodparam><type>mixed</type><parameter>object_or_class</parameter></methodparam>
<methodparam><type>string</type><parameter>class</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>allow_string</parameter><initializer>&false;</initializer></methodparam>
</methodsynopsis>
<para>
Проверяет, относится ли объект <parameter>object_or_class</parameter>
к указанному типу объекта или имеет этот тип объекта в качестве одного из своих родителей.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>object_or_class</parameter></term>
<listitem>
<para>
Имя класса или объект
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>class</parameter></term>
<listitem>
<para>
Имя класса или интерфейса.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>allow_string</parameter></term>
<listitem>
<para>
Если параметр установлен в &false;, то не допускается имя класса в виде строки
в качестве параметра <parameter>object_or_class</parameter>. Это также предотвращает вызов
автозагрузчика, если класс не существует.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Возвращает &true;, если объект принадлежит данному классу или
является ли этот класс одним из его родителей, иначе возвращается &false;.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>is_a</function></title>
<programlisting role="php">
<![CDATA[
<?php
// объявление класса
class WidgetFactory
{
var $oink = 'moo';
}
// создание нового объекта
$WF = new WidgetFactory();
if (is_a($WF, 'WidgetFactory')) {
echo "да, \$WF всё ещё WidgetFactory\n";
}
?>
]]>
</programlisting>
</example>
<example>
<title>Использование оператора <emphasis>instanceof</emphasis></title>
<programlisting role="php">
<![CDATA[
<?php
if ($WF instanceof WidgetFactory) {
echo 'Да, $WF - WidgetFactory';
}
?>
]]>
</programlisting>
</example>
</para>
</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>
</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:"~/.phpdoc/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
-->