How to property_exists() function to check if the a property exists in a specified class in PHP

1 Answer

0 votes
class Test {
    public $p_var;
    public function f() { echo($p_var); }
}
   
if (property_exists('Test', 'p_var'))
    echo "property exists<br />";

if (property_exists('Test', 'P_var'))
    echo "property exists<br />";
else
    echo "property NOT exists<br />"; 
   
/*
run:
 
property exists
property NOT exists
    
*/

 



answered Mar 15, 2016 by avibootz
...