mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 08:22:08 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@328918 c90b9560-bf6c-de11-be94-00142212c4b1
171 lines
4.4 KiB
XML
171 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 0296bdbc0ea6902e95564a8bb1d2f762a2db6964 Maintainer: seros Status: ready -->
|
|
<!-- Reviewed: yes Maintainer: seros -->
|
|
<refentry xml:id="function.is-a" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>is_a</refname>
|
|
<refpurpose>Comprueba si un objeto es de una clase o tiene esta clase como una de sus madres</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&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>
|
|
<methodparam choice="opt"><type>bool</type><parameter>allow_string</parameter><initializer>&false;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Comprueba si el objeto dado por <parameter>object</parameter> es de esta clase o tiene
|
|
esta clase como una de sus madres.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>object</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El objeto evaluado
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>class_name</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El nombre de la clase
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>allow_string</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Si este parámetro se establece a &false;, no se permite una cadena de nombre de la clase como
|
|
<parameter>object</parameter>. Esto también evita llamar al autocargador si la clase no existe.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve &true; si el objeto es de esta clase o tiene esta clase como una de sus
|
|
madres, &false; si no.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.3.9</entry>
|
|
<entry>
|
|
Se añadió el parámetro <parameter>allow_string</parameter>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>5.3.0</entry>
|
|
<entry>
|
|
Esta función ya no está obsoleta, y por lo tanto
|
|
ya no lanza advertencias de tipo <constant>E_STRICT</constant>.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>5.0.0</entry>
|
|
<entry>
|
|
Esta funcion se volvió obsoleta en favor del operador
|
|
<link linkend="language.operators.type">instanceof</link>.
|
|
Llamar a esta función resultará en una
|
|
advertencia de tipo <constant>E_STRICT</constant>.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>is_a</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// definir una clase
|
|
class FábricaTrastos
|
|
{
|
|
var $oink = 'moo';
|
|
}
|
|
|
|
// crear un nuevo objeto
|
|
$WF = new FábricaTrastos();
|
|
|
|
if (is_a($WF, 'FábricaTrastos')) {
|
|
echo "Sí, \$WF es todavía un FábricaTrastos\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<example>
|
|
<title>Usar el operador <emphasis>instanceof</emphasis> en PHP 5</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
if ($WF instanceof FábricaTrastos) {
|
|
echo 'Sí, $WF es un FábricaTrastos';
|
|
}
|
|
?>
|
|
]]>
|
|
</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
|
|
-->
|