1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-25 16:22:18 +01:00
Files
archived-doc-ru/reference/classobj/functions/is-a.xml
Mikhail Alferov b89d01e1e9 Update is-a.xml
2024-03-31 14:33:40 +03:00

143 lines
4.4 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: fd65805e83f7dc3b12ab5844cafc4489dc367a27 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>
непосредственно к типу объекта <parameter>class</parameter>, или тип объекта <parameter>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;, если объект <parameter>object_or_class</parameter>
принадлежит к типу объекта <parameter>class</parameter>,
или тип объекта <parameter>class</parameter> — супертип объекта, который проверяют,
иначе &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
-->