Skip to content

Instantly share code, notes, and snippets.

@wallacemaxters
Created January 19, 2017 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallacemaxters/6ec8167206e8e063ccf688bd75a7404a to your computer and use it in GitHub Desktop.
Save wallacemaxters/6ec8167206e8e063ccf688bd75a7404a to your computer and use it in GitHub Desktop.
Quiet debug for expression/variable on shutdown (html commented)
<?php
/**
* Debug a expression/variable on shutdown with html comment
*
* @param ...$args
* @return void
* */
function quiet_debug()
{
$args = func_get_args();
register_shutdown_function(function () use ($args) {
$isCli = php_sapi_name() === 'cli';
!$isCli && print '<!--' . PHP_EOL;
foreach ($args as $arg) {
is_scalar($arg) ? var_dump($arg) : print_r($arg);
}
!$isCli && print '-->' . PHP_EOL;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment