How to use PHP error reporting function error_reporting()?

青灯夜游
Release: 2023-03-07 12:14:01
Original
2037 people have browsed it

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.

How to use PHP error reporting function error_reporting()?

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)
Copy after login

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

How to use PHP error reporting function error_reporting()?

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

Copy after login

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!

Related labels:
php
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
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!