Skip to content

Instantly share code, notes, and snippets.

@alixaxel
Created January 29, 2013 21:42
Show Gist options
  • Save alixaxel/4668175 to your computer and use it in GitHub Desktop.
Save alixaxel/4668175 to your computer and use it in GitHub Desktop.
<?php
public static function Dump()
{
foreach (func_get_args() as $argument)
{
switch (gettype($argument))
{
case 'array':
case 'object':
$result = rtrim(print_r($argument, true));
break;
case 'resource':
$result = sprintf('%s (#%u)', get_resource_type($argument), $argument);
break;
default:
$result = stripslashes(preg_replace("~^'|'$~", '', var_export($argument, true)));
break;
}
if (strcmp('cli', PHP_SAPI) !== 0)
{
if (strpbrk($result, '<>') !== false)
{
$result = str_replace(array('<', '>'), array('&lt;', '&gt;'), $result);
}
$result = '<pre style="background: #df0; margin: 5px; padding: 5px; text-align: left;">' . $result . '</pre>';
}
echo $result . "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment