Specifications

E_ALL itself is effectively a combination of all the other error types. It could be replaced by the
other levels ORed together using the bitwise or operator (|).
E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING |
E_COMPILE_ERROR |E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING |
E_USER_NOTICE
Similarly, the default error reporting level could be specified by all error levels except notice
ORed together.
E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR |
E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE
Altering the Error Reporting Settings
You can set the error reporting settings globally, in your php.ini file or on a per script basis.
To alter the error reporting for all scripts, you can modify these four lines in the default
php.ini file:
error_reporting = E_ALL & ~E_NOTICE
display_errors = On
log_errors = Off
track_errors = Off
The default global settings are to
report all errors except notices
output error messages as HTML to standard output
not log error messages to disk
not track errors, storing the error in the variable $php_errormsg
The most likely change you are to make is to turn the error reporting level up to E_ALL. This
will result in many notices being reported, for incidents that might indicate an error, or might
just result from the programmer taking advantage of PHPs weakly typed nature and the fact
that it automatically initializes variables to 0.
While debugging, you might find it useful to set the error_reporting level higher. In produc-
tion code, if you are providing useful error messages of your own, it might be more profes-
sional looking to turn display_errors off and to turn log_errors on, while leaving the
error_reporting level high. You will then be able to refer to detailed errors in the logs if
problems are reported.
Building Practical PHP and MySQL Projects
P
ART V
490
29 7842 CH23 3/6/01 3:41 PM Page 490