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.
<?php
$num = 123;
$str = “Joe”;
$arr = array(1, 2, 3);
print_r($num);
print_r($str);
print_r($arr);
?>
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.