How to print properties of stdClass object in PHP?

I have an array containing an object of a standard class. How to return properties (print them) in a stdClass object?

+5
source share
2 answers

you can see them with var_dump($myObject);

+9
source

If you just want to print, you can use var_dump()or print_r().

var_dump($obj);
print_r($obj);

If you want an array of all properties and their values ​​to use get_object_vars().

$properties = get_object_vars($obj);
print_r($properties);
+15
source

All Articles