Re: Finer points of debugging: vardump vs. print_r
| From: | Philip Olson | Date: | Mon, 09 Apr 2001 20:08:07 +0000 |
| Subject: | Re: Finer points of debugging: vardump vs. print_r | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-47868@lists.php.net to get a copy of this message | ||
Here's some info about the two functions.
Descriptions (from manual) :
--------------------------------
print_r -- Prints human-readable information about a variable
(PHP 4)
var_dump -- Dumps information about a variable
(PHP 3 >= 3.0.5, PHP 4)
An example :
--------------------------------
<pre>
<?php
$example = array ('str' => 'is good',
'letters' => array
('a','b','c'),
'integer' => 31,
'float/double' => 35.3787,
24 => 'hello');
echo 'print_r :'. "\n\n";
print_r ($example);
echo 'var_dump :'. "\n\n";
var_dump ($example);
?>
</pre>
Output (layout altered) :
---------------------------------
print_r :
Array
(
[str] => is good
[letters] => Array
(
[0] => a
[1] => b
[2] => c
)
[integer] => 31
[float/double] => 35.3787
[24] => hello
)
var_dump :
array(4)
{
["str"] => string(7) "is good"
["letters"] => array(3)
{
[0] => string(1) "a"
[1] => string(1) "b"
[2] => string(1) "c"
}
["integer"] => int(31)
["float/double"] => float(35.3787)
[24] => string(5) "hello"
}
Manual Entries :
--------------------------------
http://www.php.net/manual/en/function.print-r.php
http://www.php.net/manual/en/function.var-dump.php
Regards,
Philip
(test: print var dump faq8490)
On Tue, 10 Apr 2001, John Lim wrote:
> Just a question that has been besetting me for a while:
>
> which is better for debugging -- vardump( ) or print( ) ?
>
> Does anyone have a preference? Why? Is one better than the other?
> Thanks for answering this prickly question!
>
> John Lim
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
Philip Olson
http://www.cornado.com/