From earlier versions to PHP 5, released on July 13, 2004, error reporting was fairly straightforward. In addition to carefully writing programs, you should also pay attention to some specific PHP configuration items:
Theerror_reporting
item sets the level of error reporting. Whether it is a development or deployment environment, it is strongly recommended to set this project to E_ALL.
Thedisplay_errors
item determines whether errors are displayed on the screen (included in the output). It should be set to On in development so that errors are discovered during development; it should be set to Off in a deployment environment so that errors will be hidden from all users (and potential attackers).
Thelog_errors
item determines whether errors are written to the log. Although this incurs a performance penalty, it is necessary for infrequent errors. If logging errors to the hard drive creates a significant I/O load, this may deserve more attention than the efficiency of the application. Should be set to On in the deployment environment.
Theerror_log
item determines the location and name of the log file. Be sure to ensure that the web server has permissions for the specified file.
Setting error_reporting to E_ALL is helpful to force initialization of variables, since using an undefined variable will generate a notice.
Note that each of these items can be set using ini_set() without requiring access to php.ini or other operations to set these items.
A very good error handling and reporting function is described in the PHP manual:
http://www.php.net/manual/en/ref.errorfunc.php
PHP 5 includes exception handling. For more information, please see: