Let\'s face it, debug_backtrace()
output is not very pretty. Did anyone code a wrapper?
And what\'s your favourite pretty var_dump()
(which is
My favorite var_dump
snippet is one I made years ago and have been working on perfecting ever since. I know there are lib's out there that create really pretty fancy dumps with accordion menus and all, but I just want a simple layout, easy to read, maybe a little HTML, and as portable as a single code-snippet method can be. Thus my function:
function preDump() { // use string "noEcho" to just get a string return only
$args = func_get_args();
$doEcho = TRUE; $sb;
if ($args) {
$sb = '';
}
else {
$sb = '';
}
if ($doEcho) echo($sb);
return $sb;
}
Use is extremely simple. It takes infinite parameters. Also, it shows everything within simple fieldsets
for each preDump
called, as well as separating each parameter into its own pre
tag, thus making it clean and easy to read. Each pre
tag also contains a header showing the gettype
of each parameter, and, if it's an object, it will also show the class name
.
Use as easy as var_dump();
preDump(TRUE, 101, 'this is a string', array( 'array', 'here' ), (object)array ( 'this' => 'is', 'an' => 'object' ), $someXMLvariable);
You can also use it to get the dump as a simple string and then echo when you see fit:
$bob = preDump($someParam1, $someParam2, 'noEcho'); // 'noEcho' causes it to return as string only