Created
December 7, 2018 09:44
-
-
Save ManojKiranA/39210a924eae0bc566624a97ccb1db89 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* 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