Home » » property_exists

property_exists

Written By 1 on Sunday, September 30, 2012 | 8:33 AM

bool property_exists ( mixed $class , string $property )

This function checks if the given property exists in the specified class.


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

?>

5.3.0 This function checks the existence of a property independent of accessibility.


64 PHP视频教程对象method exists property exists instanceof

0 Comment:

Post a Comment