Skip to content

Instantly share code, notes, and snippets.

@og-shawn-crigger
Created August 6, 2012 09:44
Show Gist options
  • Select an option

  • Save og-shawn-crigger/3272912 to your computer and use it in GitHub Desktop.

Select an option

Save og-shawn-crigger/3272912 to your computer and use it in GitHub Desktop.
Phil Sturgeons dump method with dark background for night coding
if ( ! function_exists('dump'))
{
/**
* Outputs the given variables with formatting and location. Huge props
* out to Phil Sturgeon for this one (http://philsturgeon.co.uk/blog/2010/09/power-dump-php-applications).
* To use, pass in any number of variables as arguments.
*
* @return void
*/
function dump()
{
list($callee) = debug_backtrace();
$arguments = func_get_args();
$total_arguments = count($arguments);
echo '<fieldset style="background: #444; !important; border:2px red solid; padding:5px">';
echo '<legend style="background:lightgrey; padding:5px;">'.$callee['file'].' @ line: '.$callee['line'].'</legend><pre style="color:#FFF;">';
$i = 0;
foreach ($arguments as $argument)
{
echo '<br/><strong>Debug #'.(++$i).' of '.$total_arguments.'</strong>: ';
if ( (is_array($argument) || is_object($argument)) && count($argument))
{
print_r($argument);
}
else
{
var_dump($argument);
}
}
echo '</pre>' . PHP_EOL;
echo '</fieldset>' . PHP_EOL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment