Skip to content

Instantly share code, notes, and snippets.

@sebald
Created November 5, 2011 11:24
Show Gist options
  • Save sebald/1341407 to your computer and use it in GitHub Desktop.
Save sebald/1341407 to your computer and use it in GitHub Desktop.
better print(_r) function for debugging
<?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