Skip to content

Instantly share code, notes, and snippets.

@MarceauKa
Created March 25, 2020 12:38
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 MarceauKa/8c563734eb6c71fe57f16e0fb8acb6b4 to your computer and use it in GitHub Desktop.
Save MarceauKa/8c563734eb6c71fe57f16e0fb8acb6b4 to your computer and use it in GitHub Desktop.
PHP `dd` helper
<?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