PHP error_reporting() function
Example
Define different error levels to report:
<?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); // Equivalent to error_reporting(E_ALL); ini_set("error_reporting", E_ALL); // Report all errors except E_NOTICE error_reporting(E_ALL & ~E_NOTICE); ?>
Definition and Usage
The error_reporting() function specifies what kind of PHP errors should be reported.
The error_reporting() function can set the error_reporting directive at runtime.
PHP has many error levels, and this function can set the level at runtime. level, error_reporting() will only return the current error reporting level.
Syntax
error_reporting(level);
Parameter | Description |
---|---|
level |
Optional. Specifies a new error_reporting level. It can be a bitmask or a named constant. Note:It is strongly recommended to use named constants to ensure compatibility with future versions. Due to the addition of error levels and the increase in integer value ranges, older integer-based error levels may not always behave as expected. The predefined constants describe the available error level constants and their actual meanings. |
Technical Details
Return Value: | Returns the old error_reporting Level, or at level Returns the current level if no parameters are given. |
---|---|
PHP Version: | 4.0+ |