Posted By

PeteW on 05/08/09


Tagged

php display debug printr vardump


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

PeteW
vali29
jplr


PHP Debug Display


 / Published in: PHP
 

URL: http://twitter.com/PeteWilliams

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

  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. }

Report this snippet  

You need to login to post a comment.