Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP error_reporting() Function

PHP error_reporting() Function


PHP Error Reference Manual 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 previous 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, but for compatibility with future PHP versions, using constant names is recommended.

Reporting level

Value Constant Description
1 E_ERROR Fatal run-time errors. Errors that cannot be recovered from. Execution of the script is halted.
2 E_WARNING Non-fatal run-time errors. Execution of the script is not halted.
4 E_PARSE Compile-time parse errors. Parse errors should only be generated by the parser.
8 E_NOTICE Run-time notices. The script found something that might be an error, but could also occur during normal script execution.
16 E_CORE_ERROR Fatal errors that occur during PHP startup. This is like an E_ERROR in the PHP core.
32 E_CORE_WARNING Non-fatal errors that occur during PHP startup. This is like an E_WARNING in the PHP core.
64 E_COMPILE_ERROR Fatal compile-time errors. This is like an E_ERROR generated by the Zend Scripting Engine.
128 E_COMPILE_WARNING Non-fatal compile-time errors. This is like an E_WARNING generated by the Zend Scripting Engine.
256 E_USER_ERROR User-generated fatal errors. This is like an E_ERROR generated by the programmer using the PHP function trigger_error().
512 E_USER_WARNING User-generated non-fatal errors. This is like an E_WARNING generated by the programmer using the PHP function trigger_error().
1024 E_USER_NOTICE User-generated notices. This is like an E_NOTICE generated by the programmer using the PHP function trigger_error().
2048 E_STRICT Run-time notices. PHP suggests that you change your code to improve interoperability and compatibility.
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 errors and warnings, except E_STRICT (since PHP 6.0, E_STRICT is part of E_ALL).

Example


PHP Error Reference Manual Complete PHP Error Reference Manual