(PHP 5 >= 5.1.0, PHP 7)
property_exists — ����������Ƿ���и�����
�������������� property
�Ƿ������ָ�������У��Լ��Ƿ����ڵ�ǰ��Χ�ڷ��ʣ���
Note:
As opposed with isset(), property_exists() returns
TRUE
even if the property has the valueNULL
.
class
�ַ�����ʽ��������Ҫ�������һ������
property
���Ե�����
��������Դ����� TRUE
������������� FALSE
�������� NULL
��
Note:
����������֪�࣬ʹ�ô˺�����ʹ���κ���ע��� autoloader��
Note:
The property_exists() function cannot detect properties that are magically accessible using the __get magic method.
�汾 | ˵�� |
---|---|
5.3.0 | This function checks the existence of a property independent of accessibility. |
Example #1 A property_exists() example
<?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();
?>