PHP error_reporting() 函数
实例
规定不同的错误级别报告:
<?php // 关闭错误报告 error_reporting(0); // 报告 runtime 错误 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 which 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 during script execution. If the optional parameter is not set 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 of integer value ranges, the error levels based on integers may not always perform as expected. The available error level constants and their actual meanings are described in predefined constants. |
Technical Details
Return value: | Returns the old error_reporting Level, or in level Returns the current level if no parameters are given. |
---|---|
PHP Version: | 4.0+ |