Last active
January 5, 2018 07:33
-
-
Save ivuorinen/4344854 to your computer and use it in GitHub Desktop.
debug() to aid in your development
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 magical function to use in your code | |
* | |
* @author Ismo Vuorinen <https://github.com/ivuorinen> | |
* | |
* @param mixed $thing The thing you want to see | |
* @param bool $echo Should we return or echo the output [default: false] | |
* @param string $title If you need to mark your outputs | |
* | |
* @return mixed Uses var_export to get the data out | |
**/ | |
function debug($thing = null, $echo = false, $title = '') | |
{ | |
$export = var_export($thing, true); | |
if ($echo) { | |
echo sprintf("\n<pre>%s\n%s\n</pre>\n", $title, $export); | |
return true; | |
} | |
return $export; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment