Jump to Navigation

048 - print_r(), var_dump(), var_export()

var_dump() is a similar function to print_r(). It does largely the same thing, but it prints out size of variables,
it does not print out nonpublic data in objects, and it does not hava the option to pass a second parameter
to return its output.

print_r() :

Array
(
[0] => value1
[1] => value01
[2] => value001
)

var_dump() :

array(3) {
[0] =>
string(6) "value1"
[1] =>
string(7) "value01"
[2] =>
string(8) "value001"
}

var_export() is similar to both var_dump() and print_r(). The difference with var_export() is that
it prints out variable information in a style that can be used as PHP code.

var_export() :

array (
0 => 'value1',
1 => 'value01',
2 => 'value001',
)


Main menu 2

Story | by Dr. Radut