Created
November 5, 2011 11:24
-
-
Save sebald/1341407 to your computer and use it in GitHub Desktop.
better print(_r) function for debugging
This file contains hidden or 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
<?php | |
function print_a(){ | |
$numargs = func_num_args(); | |
if($numargs>1){ | |
$out = ''; | |
ob_start(); | |
echo "<div style='background-color:#FFCC33;border:1px solid black;margin:3px;padding:5px;'>"; | |
for($a=0;$a<$numargs;$a++) | |
print_a(func_get_arg($a)); | |
echo "</div>"; | |
$out .= ob_get_contents(); | |
ob_end_clean(); | |
echo $out; | |
}else{ | |
echo "<pre style='background-color:#FFDF80;border:1px solid #000;margin:3px;padding:5px;'>"; | |
$a = func_get_arg(0); | |
$a = (is_bool($a))?(($a)?'true':'false'):$a; | |
print_r($a); | |
echo "</pre>"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment