Looping through all the properties of object php
<p>How can I loop through all the properties of object?. Right now I have to write a new code line to print each property of object</p>

<pre><code>echo $obj-&gt;name;
echo $obj-&gt;age;
</code></pre>

<p>Can I loop through all the properties of an object using foreach loop or any loop?</p>

<p>Something like this</p>

<pre><code>foreach ($obj as $property =&gt; $value)  
</code></pre>
