Basically the differences between print_r()
and var_dump()
are that the second in addition to displaying the value / structure of the variable shows its type and size in the case of strings. Do not return value of the expression / variable in this case var_export () is recommended.
var_dump ()
$arr = array('a', 'b', 'c', 'teste');
var_dump($arr);
Output:
array (size=4)
0 => string 'a' (length=1)
1 => string 'b' (length=1)
2 => string 'c' (length=1)
3 => string 'teste' (length=5)
print_r ()
$arr = array('a', 'b', 'c', 'teste');
print_r($arr);
Output:
Array
(
[0] => a
[1] => b
[2] => c
[3] => teste
)