Usage and examples of php error_reporting() function

怪我咯
Release: 2023-03-13 12:02:02
Original
993 people have browsed it

error_reporting() FunctionKneel down and tell you what kind of PHP error should be reported. This function enables setting 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(level);
Copy after login
ParametersDescription
level

Optional. Specifies the new error_reporting level. 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 the integervalue range, older integer-based error levels will not always behave as expected.

The available error level constants and their actual meanings are described in predefined constants.

Example:
Any number of the above options can be connected with "OR" (using OR or |), so that all required options can be reported Wrong level.
For example, the following code turns off user-defined errors and warnings, performs certain operations, and then returns to the original error level:

<?php
//禁用错误报告
error_reporting(0);
 
//报告运行时错误
error_reporting(E_ERROR | E_WARNING | E_PARSE);
 
//报告所有错误
error_reporting(E_ALL);
?>
Copy after login

The above is the detailed content of Usage and examples of php error_reporting() function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!