Created
March 25, 2020 12:38
-
-
Save MarceauKa/8c563734eb6c71fe57f16e0fb8acb6b4 to your computer and use it in GitHub Desktop.
PHP `dd` helper
This file contains hidden or 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 | |
function dd() { | |
ob_start(); | |
array_map(function ($item) { | |
var_dump($item); | |
}, func_get_args()); | |
$dump = ob_get_clean(); | |
$format = php_sapi_name() == "cli" ? '%s' : '<pre>%s</pre>'; | |
die(sprintf($format, $dump)); | |
} | |
dd('foo', ['bar' => 'baz'], new DateTime); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment