property_exists

(PHP 5 >= 5.1.0, PHP 7)

property_exists锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷欠锟斤拷锟叫革拷锟斤拷锟斤拷

说锟斤拷

property_exists ( mixed $class , string $property ) : bool

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 property 锟角凤拷锟斤拷锟斤拷锟街革拷锟斤拷锟斤拷锟斤拷校锟斤拷约锟斤拷欠锟斤拷锟斤拷诘锟角帮拷锟轿э拷诜锟斤拷剩锟斤拷锟�

Note:

As opposed with isset(), property_exists() returns TRUE even if the property has the value NULL.

锟斤拷锟斤拷

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();

?>

锟轿硷拷

  • method_exists() - 锟斤拷锟斤拷锟侥凤拷锟斤拷锟角凤拷锟斤拷锟�