PHP error_reporting()Functions
Complete PHP Error Reference Manual
Definition and Usage
The error_reporting() function specifies which errors are reported.
This function sets the error reporting level for the current script.
This function returns the old error reporting level.
Syntax
error_reporting(report_level)
| Parameters | Description |
|---|---|
| report_level | Optional. Specifies the error reporting level for the current script. Both numeric values and constant names are accepted; however, for compatibility with future PHP versions, the use of constant names is recommended. |
Reporting Levels
| Value | Constants | Description |
|---|---|---|
| 1 | E_ERROR | Fatal errors at runtime. Errors that cannot be fixed. Stop the execution of the script. |
| 2 | E_WARNING | Non-fatal errors at runtime. The execution of the script is not stopped. |
| 4 | E_PARSE | Parse errors at compile time. Parse errors should only be generated by the parser. |
| 8 | E_NOTICE | Notices at runtime. The script finds something that may be an error, but it may also occur during normal script execution. |
| 16 | E_CORE_ERROR | Fatal errors at PHP startup. This is like E_ERROR from the PHP core. |
| 32 | E_CORE_WARNING | Non-fatal errors at PHP startup. This is like E_WARNING from the PHP core. |
| 64 | E_COMPILE_ERROR | Fatal errors at compile time. This is like E_ERROR generated by the Zend Script Engine. |
| 128 | E_COMPILE_WARNING | Non-fatal errors at compile time. This is like E_WARNING generated by the Zend Script Engine. |
| 256 | E_USER_ERROR | User-generated fatal errors. This is like E_ERROR generated by the programmer using the PHP function trigger_error(). |
| 512 | E_USER_WARNING | User-generated non-fatal errors. This is like E_WARNING generated by the programmer using the PHP function trigger_error(). |
| 1024 | E_USER_NOTICE | User-generated notices. This is like E_NOTICE generated by the programmer using the PHP function trigger_error(). |
| 2048 | E_STRICT | Notices at runtime. PHP suggests you change your code to improve the interoperability and compatibility of the code. |
| 4096 | E_RECOVERABLE_ERROR | Catchable fatal errors. This is like an E_ERROR that can be caught by a user-defined handler (see set_error_handler()). |
| 8191 | E_ALL | All levels of errors and warnings, except E_STRICT (as of PHP 6.0, E_STRICT will be part of E_ALL). |
Examples
<?php
//Disable error reporting
error_reporting(0);
//Report runtime errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//Report all errors
error_reporting(E_ALL);
?>
//Disable error reporting
error_reporting(0);
//Report runtime errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//Report all errors
error_reporting(E_ALL);
?>
Complete PHP Error Reference Manual Other Extensions