Skip to content

Instantly share code, notes, and snippets.

@openam
Created February 26, 2014 17:25
Show Gist options
  • Select an option

  • Save openam/9234221 to your computer and use it in GitHub Desktop.

Select an option

Save openam/9234221 to your computer and use it in GitHub Desktop.
A simple PHP debug function, similar to CakePHP
<?php
/**
* debug is a simple function to show which line and file a debug call came from
* including the contents of print_r() wrapped in a <pre> tag
*
* @param string $value
* @return void
*/
function debug($value = '') {
$backtrace = debug_backtrace();
echo '<h5>' . $backtrace[0]['file'] . ' - Line: ' . $backtrace[0] ['line'] . '</h5>';
echo "<pre>"; print_r($value); echo "</pre>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment