Created
January 19, 2017 11:10
-
-
Save wallacemaxters/6ec8167206e8e063ccf688bd75a7404a to your computer and use it in GitHub Desktop.
Quiet debug for expression/variable on shutdown (html commented)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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