Different between the var_dump() and print_r()?
Answers were Sorted based on User's Feedback
Answer / nagachowdary
var_dump() prints values and it's datatypes.in case of
print_r() it will print only values
| Is This Answer Correct ? | 23 Yes | 3 No |
Answer / nimesha
Print_r will display only values,but var_dump will display
data types too
Eg :
<?php
$a = array('aaa','bbb',11);
?>
Output of var_dump :
array(3) { [0]=> string(3) "aaa" [1]=> string(3) "bbb"
[2]=> int(11) }
Output of print_r :
Array ( [0] => aaa [1] => bbb [2] => 11 )
| Is This Answer Correct ? | 9 Yes | 2 No |
Answer / rubina
The difference between the two is:
Var_dump() returns the datatype also of the variable which
print_r() does not.
Eg:
$query="Select fname from table where id=20";
$result=mysql_query($query);
$row=mysql_fetch_row($result);
print_r($query);
o/p
---------------
SELECT fname FROM information where id=53
var_dump($query);
o/p
----------------
string(43) " SELECT fname FROM information where id=53"
| Is This Answer Correct ? | 7 Yes | 3 No |
How to write the form tag correctly for uploading files?
What is the basic function to search files for lines (or other units of text) that contain a pattern.
Is array function in php?
How a constant is defined in a php script?
How do you remove whitespace from the beginning and end of a $string variable?
How can I display text with a php script?
Is null in php?
how to display and include the user system date/time in a php program/project
What is the use of count() function in php?
What is the difference between Joomla and Drupal?
8 Answers IBM, Procon IT Solutions, T3 Softwares,
Are sessions stateless?
How should a model be structured in mvc?