PHP Debug Display


/ Published in: PHP
Save to your folder(s)

A simple replacement for print_r or whatever you use to display debug info.


Copy this code and paste it in your HTML
  1. /**
  2.  * simple display function for debugging
  3.  *
  4.  * @param mix $mixObj
  5.  * @param string $strLabel
  6.  */
  7. function display( $mixObj, $strLabel = null) {
  8.  
  9. // show nothing on production server
  10. if ( 1 == ini_get( 'display_errors' ) ) {
  11.  
  12. $backtrace = debug_backtrace();
  13.  
  14. echo "
  15. <div style=\"border: 1px dotted #000; width: 100%;\">
  16. <strong>$strLabel</strong> - Called from: " .$backtrace[0]['file'] . " (line " . $backtrace[0]['line'] . ")
  17. <pre style=\"border: 1px dotted #000; margin-top: 0px\">" . print_r($mixObj, true ) . "</pre>
  18. </div>";
  19.  
  20. }
  21.  
  22. }

URL: http://twitter.com/PeteWilliams

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.