/ Published in: PHP
URL: http://www.milesj.me/blog/read/39/creating-a-simple-debug-function
Expand |
Embed | Plain Text
/** * Outputs/Debugs a variable and shows where it was called from * @param mixed $var * @param boolean $dump * @param boolean $backtrace * @return string */ function debug($var, $dump = false, $backtrace = true) { if ($backtrace) { echo '<strong>' . trim(str_replace($_SERVER['DOCUMENT_ROOT'], '', $calledFrom[0]['file'])) . '</strong> (line <strong>' . $calledFrom[0]['line'] . '</strong>)'; } echo '<pre class="debug">'; $function = ($dump) ? 'var_dump' : 'print_r'; $function($var); echo '</pre>'; } }
You need to login to post a comment.
