Programming Basics
  Home arrow Programming Basics arrow Page 5 - Coding
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PROGRAMMING BASICS

Coding
By: lig
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2006-01-17

    Table of Contents:
  • Coding
  • Thinking before Coding
  • Commenting
  • Coding Style
  • Error Reporting
  • Error Handling
  • Security
  • Reinventing the Wheel
  • Advanced
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Coding - Error Reporting


    (Page 5 of 10 )

    You can not fix an error if you don't know what it is. Believe it or not, being told of errors is a good thing, otherwise you would have a problem and no way of knowing there is a problem. PHP provides multiple ways of informing you of errors that occur in your scripts.

    php.ini

    There are a number of settings you can play with in the php.ini file that deal with error reporting. Settings made in php.ini affect ALL PHP scripts running on the server, not just yours. All the settings have documentation to help you customize it (check out the PHP manual). There is of course the error_reporting setting, but there is also display_error, log_errors, and the error_log settings. The display_error setting is just whether or not to display any error messages on the screen, which is typically set to false on production servers. Instead, error messages can be logged to a specific log file by setting log_errors and error_log.

    Script

    If you don't have access to the php.ini file that runs on your server--have no fear. You still can have some control over error reporting. The simplest way to make sure you can see all the errors in your specific script is to not suppress them with @. If you absolutely must use the @, add it AFTER all debugging and testing of your script. After that, set your scripts error_reporting() to E_ALL (or E_ALL | E_STRICT for PHP5). We can use the following example in our code to redirect all errors to a logfile outside a web accessible directory when we’re in production:

    <?php
    error_reporting
    (E_ALL E_STRICT);
    ini_set("display_errors"False);
    ini_set("log_errors"True);
    ini_set("error_log""../outside/of/web/root/error_log.txt");
    ?>

    More Programming Basics Articles
    More By lig


       · The link to Chris Shiflett's blog is broken.The blog can be found at...
       · Be careful when you log stuff to rotate the logfile, otherwise it'll fill up and...
       · Sorry about that.
       · Thanks very much for taking the time to write this. Although most was over my head,...
       · That was pretty convincing Gospel. I hope this stuff is gonna work for...
     

    PROGRAMMING BASICS ARTICLES

    - PHP: Hypertext Preprocessor: What is it?
    - Loops and PHP Decision Making
    - Operators, Conditionals, and PHP Decision-Ma...
    - PHP Decision-Making
    - Coding
    - Server Statistics
    - Looping in PHP
    - Cookies in PHP
    - Working with text files
    - Beginning Object Oriented Programming in PHP
    - A Tour of Decision Making Structures in PHP
    - PHP Strings Primer
    - PHP Control Structures
    - Intro to Vim
    - Reading Directorys with PHP





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek