Inspecting Objects: Simple Trick
Submitted by amitsedai on Wed, 06/20/2012 - 17:55How often have you felt the need to display a PHP Object in a readable manner? We are all very familiar with the use of the print_r() function. However, print_r() gives a difficult to read output and we end up matching braces to figure out the exact structure of complex objects. Here is a small trick which you can use to see the print_r() output in a 'Display for Humans' format.
echo '<pre>';
print_r($object);
echo '</pre>';
Let's see an example(borrowed from PHP.net):
<?php