In PHP, the error reporting function error_reporting() is used to specify what kind of PHP errors should be reported, the syntax is "error_reporting(level)"; use this function to set the error level when the script is running, if not set it is optional parameter level, only the current error reporting level is returned.
Recommended: "PHP Video Tutorial"
error_reporting() function specifies what kind of PHP errors you should report .
The error_reporting() function can set the error_reporting directive at runtime.
PHP has many error levels. Use this function to set the level when the script is running. If the optional parameter level is not set, error_reporting() will only return the current error reporting level.
Syntax
error_reporting(report_level)
Parameters:
report_level: Optional. Specifies the error reporting level for the current script. Both value numbers and constant names are accepted, however, for compatibility with future PHP versions, it is recommended to use constant names.
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 the range of integer values, older integer-based error levels will not always behave as expected.
Reporting level
Return value:Return the old error_reporting level, or the level parameter is not given Returns the current level when exiting.
Example:Specify different error level reports
For more programming-related knowledge, please visit:Introduction to Programming! !
The above is the detailed content of How to use PHP error reporting function error_reporting()?. For more information, please follow other related articles on the PHP Chinese website!