note 51119 added to function.var-dump
| From: | edwardzyang at thewritingpot dot com | Date: | Sun, 20 Mar 2005 22:06:14 +0000 |
| Subject: | note 51119 added to function.var-dump | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86722@lists.php.net to get a copy of this message | ||
If you're like me and uses var_dump whenever you're debugging, you might find these two
"wrapper" functions helpful.
This one automatically adds the PRE tags around the var_dump output so you get nice formatted
arrays.
<?php
function var_dump_pre($mixed = null) {
echo '<pre>';
var_dump($mixed);
echo '</pre>';
return null;
}
?>
This one returns the value of var_dump instead of outputting it.
<?php
function var_dump_ret($mixed = null) {
ob_start();
var_dump($mixed);
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
Fairly simple functions, but they're infinitely helpful (I use var_dump_pre() almost
exclusively now).
----
Manual Page -- http://www.php.net/manual/en/function.var-dump.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51119
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51119&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51119&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51119&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51119&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51119&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51119&report=yes
Search -- http://master.php.net/manage/user-notes.php