PHP Debugging Techniques

I really can’t improve on this page from IBM.

http://www.ibm.com/developerworks/library/os-debug/

However, some things from this page worth emphasizing are these: 

  • Debug Statements in httpd.conf:
    • You can put flags in httpd.conf that will override settings in your php.ini file:
    • For example,
      • php_flag  display_errors        on
      • php_value error_reporting       2039
    • will override the same settings in your php.ini file.
  • As the author points out, this can be usefule if you have multiple versions of PHP on your server.
  • Debug Statements in php.ini
    • display_errors = On/Off
    • error_reporting = E_ALL & ~E_NOTICE
  • Debug Statements for $_GET:
    • This is handy, and I hadn’t thought of it before.  An improvement would be to add a class called “displaygets”, and make it either hidden or visible  using JQuery,  and upon the presence of a debug flag,  either show or hide the $_GET information in its own div….
      foreach($_GET as $key => $i){
         print("Correct data? " . $_GET[$key] . "<br>");
         print("$key=$j<br>");
      }

 

Leave a Reply