Definition and usage:
Error_reporting () sets the PHP error level and returns the current level.
Function Syntax:
Error_reporting (report_level)
If the level parameter is not specified, the current error level is returned. The following items are possible values of level:
Value constant description
1 E_ERROR fatal running error. The error cannot be recovered. The script is paused.
2 E_WARNING runtime warning (non-fatal error ). Non-fatal running error. script execution will not stop.
4. parsing error during E_PARSE compilation. Parsing errors are only generated by the analyzer.
8 E_NOTICE runtime reminder (these are often caused by bugs in your code, and may also be caused by intentional behavior .)
16 E_CORE_ERROR fatal error during PHP initialization.
32 E_CORE_WARNING warning during initialization (non-fatal error) during PHP startup ).
64 E_COMPILE_ERROR fatal error during compilation. This is like an E_ERROR generated by the Zend script engine.
128 E_COMPILE_WARNING warning during compilation (non-fatal error ). This is like an E_WARNING warning generated by the Zend script engine.
256 user-defined error message for E_USER_ERROR. This is like using the PHP function trigger_error (the programmer sets E_ERROR)
512 E_USER_WARNING User-Defined warning messages. This is like an E_WARNING warning set by the programmer by using the PHP function trigger_error)
1024 E_USER_NOTICE User-Defined reminder message. This is like an E_NOTICE set for a programmer using the PHP function trigger_error)
2048 E_STRICT code standardization warning. PHP is allowed to recommend how to modify the code to ensure the best interoperability forward compatibility.
4096 E_RECOVERABLE_ERROR. This is like an E_ERROR, but it can be captured through user-defined processing (see set_error_handler ())
8191 all E_ALL errors and warnings (excluding E_STRICT) (E_STRICT will be part of E_ALL as of PHP 6.0)
Example:
Any number of the above options can be connected with "OR" (OR |), so that all required levels of errors can be reported.
For example, the following code disables User-Defined errors and warnings, performs some operations, and then restores to the original error level:
<? Php
// Disable Error Reporting
Error_reporting (0 );
// Report running errors
Error_reporting (E_ERROR | E_WARNING | E_PARSE );
// Report all errors
Error_reporting (E_ALL );
?>