fork download
  1. <?php
  2.  
  3. class Foo {
  4. public $prop = null;
  5. }
  6.  
  7. class Bar {
  8. public function __construct() {
  9. $this->prop = null;
  10. }
  11. }
  12.  
  13. var_dump(property_exists('Foo', 'prop'));
  14. var_dump(property_exists('Bar', 'prop'));
  15.  
  16. $foo = new Foo;
  17. $bar = new Bar;
  18.  
  19. var_dump(property_exists($foo, 'prop'));
  20. var_dump(property_exists($bar, 'prop'));
  21.  
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
bool(true)
bool(false)
bool(true)
bool(true)