Skip to content

Instantly share code, notes, and snippets.

@ManojKiranA
Created December 7, 2018 09:44
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 ManojKiranA/39210a924eae0bc566624a97ccb1db89 to your computer and use it in GitHub Desktop.
Save ManojKiranA/39210a924eae0bc566624a97ccb1db89 to your computer and use it in GitHub Desktop.
<?php
/**
* Dumps a given variable along with some additional data.
*
* @param mixed $var
* @param bool $pretty
*/
function dd($var, $pretty = false)
{
$backtrace = debug_backtrace();
echo "\n<pre>\n";
if (isset($backtrace[0]['file'])) {
echo $backtrace[0]['file'] . "\n\n";
}
echo "Type: " . gettype($var) . "\n";
echo "Time: " . date('c') . "\n";
echo "---------------------------------\n\n";
($pretty) ? print_r($var) : var_dump($var);
echo "</pre>\n";
die;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment