search
HomeBackend DevelopmentPHP ProblemHow to use PHP error reporting function error_reporting()?

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)

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

<?php
 // 关闭错误报告
 error_reporting(0);
 
 // 报告 runtime 错误
 error_reporting(E_ERROR | E_WARNING | E_PARSE);
 
 // 报告所有错误
 error_reporting(E_ALL);
 
 // 等同 error_reporting(E_ALL);
 ini_set("error_reporting", E_ALL);
 
 // 报告 E_NOTICE 之外的所有错误
 error_reporting(E_ALL & ~E_NOTICE);
?>

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!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool