Created
September 10, 2012 17:35
-
-
Save eddmann/3692379 to your computer and use it in GitHub Desktop.
An alternative to 'var_dump'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dump() | |
{ | |
$args = func_get_args(); | |
echo "\n<pre style=\"border:1px solid #ccc;padding:10px;margin:10px;font:14px courier;background:whitesmoke;display:block;border-radius:4px;\">\n"; | |
$trace = debug_backtrace(false); | |
$offset = (@$trace[2]['function'] === 'dump_d') ? 2 : 0; | |
echo "<span style=\"color:red\">" . @$trace[1+$offset]['class'] . "</span>:" . | |
"<span style=\"color:blue;\">" . @$trace[1+$offset]['function'] . "</span>:" . | |
@$trace[0+$offset]['line'] . " " . | |
"<span style=\"color:green;\">" . @$trace[0+$offset]['file'] . "</span>\n"; | |
if ( ! empty($args)) { | |
echo "\n"; | |
call_user_func_array('var_dump', $args); | |
} | |
echo "</pre>\n"; | |
} | |
function dump_d() | |
{ | |
call_user_func_array('dump', func_get_args()); | |
die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment