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 expression/variable value in this case var_export() is recommended.
var_dump()
$arr = array('a', 'b', 'c', 'teste');
var_dump($arr);
Exit:
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);
Exit:
Array
(
[0] => a
[1] => b
[2] => c
[3] => teste
)