W3docs

How to print all properties of an object

To print all properties of an object in PHP, you can use the get_object_vars function, which returns an associative array of an object's properties.

To print all properties of an object in PHP, you can use the get_object_vars function, which returns an associative array of an object's properties. You can then iterate over the array and print each property.

Here is an example:

How to print all properties of an object in PHP?

php— editable, runs on the server

This will output the following:


name: John
age: 30
city: New York