mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-23 04:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@297830 c90b9560-bf6c-de11-be94-00142212c4b1
158 lines
3.8 KiB
XML
158 lines
3.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="function.property-exists" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>property_exists</refname>
|
|
<refpurpose>
|
|
Checks if the object or class has a property
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>property_exists</methodname>
|
|
<methodparam><type>mixed</type><parameter>class</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>property</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
This function checks if the given <parameter>property</parameter> exists in
|
|
the specified class.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
As opposed with <function>isset</function>,
|
|
<function>property_exists</function> returns &true; even if the property
|
|
has the value &null;.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>class</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The class name or an object of the class to test for
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>property</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The name of the property
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns &true; if the property exists, &false; if it doesn't exist or
|
|
&null; in case of an error.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.uses-autoload;
|
|
<note>
|
|
<para>
|
|
The <function>property_exists</function> function cannot detect properties
|
|
that are magically accessible using the <link
|
|
linkend="language.oop5.overloading.members"><literal>__get</literal></link>
|
|
magic method.
|
|
</para>
|
|
</note>
|
|
</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.0</entry>
|
|
<entry>
|
|
This function checks the existence of a property independent of
|
|
accessibility.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>A <function>property_exists</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
class myClass {
|
|
public $mine;
|
|
private $xpto;
|
|
static protected $test;
|
|
|
|
static function test() {
|
|
var_dump(property_exists('myClass', 'xpto')); //true
|
|
}
|
|
}
|
|
|
|
var_dump(property_exists('myClass', 'mine')); //true
|
|
var_dump(property_exists(new myClass, 'mine')); //true
|
|
var_dump(property_exists('myClass', 'xpto')); //true, as of PHP 5.3.0
|
|
var_dump(property_exists('myClass', 'bar')); //false
|
|
var_dump(property_exists('myClass', 'test')); //true, as of PHP 5.3.0
|
|
myClass::test();
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>method_exists</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
|
|
-->
|