Search code examples
phpphp4

How to check if a PHP object has a property in PHP4.


I would like to check if a PHP object has a property. For PHP5 I could use

if (property_exists($object, "foo")) {...}

but how can I do the same in PHP4?


Solution

  • You can use get_object_vars and check the resulting array if your property exists.

    Please refer to the the documentation on get_object_vars here: http://php.net/manual/en/function.get-object-vars.php