1) var_dump ==>> is for debugging purposes
// var_dump(array('', false, 42, array('42')));
array(4) {
[0]=> string(0) ""
[1]=> bool(false)
[2]=> int(42)
[3]=> array(1) {[0]=>string(2) "42")}
}
2) print_r =>> is for for debugging purposes, too, but does not include the member's type. It's a good idea to use if you know the types of elements in your array, but can be misleading otherwise:
Array (
[0] =>
[1] =>
[2] => 42
[3] => Array ([0] => 42)
)
3) Var_export ==> prints valid php code. Useful if you calculated some values and want the results as a constant in another script. Note that
var_export can not handle reference cycles/recursive arrays, whereas var_dump and print_r check for these.array (
0 => '',
2 => false,
2 => 42,
3 => array (0 => '42',),
)
Personally, I think
Note ======================================================================>> IMP.
var_export is the best compromise of concise and precise.Note ======================================================================>> IMP.
Echo :
It is statement not a function No return value
Not Required the parentheses
Not Print Array
Print
It is real function
Return type 1
Required the Parentheses
Not Print Array
Print_r
Print in human readable format
String not in Quotes
Not Detail Information of Variable like type and all
var_dump
All dump information of variable like type of element and sub element
No comments:
Post a Comment