PHP function of the day: print_r()

For day 17 of 21 in the “PHP Function of the day” series, I’m going to look at print_r(). We have already used print_r() on days 4, 5, and 11.

Let’s take a look.


$num = 123;

$str = “Joe”;

$arr = array(1, 2, 3);






See the output


As you can see, the function just dumps the value to the page.  The reason why it was used in the array_diff(), array(), and gettimeofday() posts is because (unlike echo()) it can handle more than just strings and numeric values.

Leave a Reply

Your email address will not be published.