public static function dump($var, $echo = true, $label = null, $flags = ENT_SUBSTITUTE)
{
$label = null === $label ? '' : rtrim($label) . ':';
ob_start();
var_dump($var);
$output = ob_get_clean();
$output = preg_replace('/\\]\\=\\>\\n(\\s+)/m', '] => ', $output);
if (IS_CLI) {
$output = PHP_EOL . $label . $output . PHP_EOL;
} else {
if (!extension_loaded('xdebug')) {
$output = htmlspecialchars($output, $flags);
}
$output = '<pre>' . $label . $output . '</pre>';
}
if ($echo) {
echo $output;
return null;
} else {
return $output;
}
}