Skip to content

Instantly share code, notes, and snippets.

@cornernote
Created November 22, 2012 02:43
Show Gist options
  • Select an option

  • Save cornernote/4129160 to your computer and use it in GitHub Desktop.

Select an option

Save cornernote/4129160 to your computer and use it in GitHub Desktop.
/**
* Debug the target with syntax highlighting on by default.
* @param null $var
* @param null $name
*/
function debug($var = null, $name = null)
{
$bt = debug_backtrace();
if ($name !== false) {
$file = str_replace(bp(), '', $bt[0]['file']);
print '<div style="background: #FFFBD6">';
if ($name)
$name = '<b>' . $name . '</b><br/>';
print '<span style="font-size:12px;">' . $name . ' ' . $file . ' on line ' . $bt[0]['line'] . '</span>';
print '<div style="border:1px solid #000;">';
}
print '<pre>';
print_r($var);
print '</pre>';
if ($name !== false) {
print '</div>';
print '</div>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment