Home > Backend Development > PHP Tutorial > Usage reference of error_reporting() function in php

Usage reference of error_reporting() function in php

WBOY
Release: 2016-07-25 08:57:24
Original
1028 people have browsed it
This article introduces the usage of the error handling function error_reporting() in PHP. Friends in need can refer to it.

In php, error_reporting() sets the error level of PHP and returns the current level.

Syntax: error_reporting(report_level)

If the parameter level is not specified, the current error level will be returned. The following are possible values ​​for level:

; Error reporting is bitwise. Or add the numbers together to get the desired error reporting level.

; E_ALL – all errors and warnings

; E_ERROR – fatal runtime error

; E_WARNING – runtime warning (non-fatal error)

; E_PARSE – compile-time parsing error

; E_NOTICE – runtime reminder (these are often caused by bugs in your code,

;It may also be caused by intentional behavior. (For example: automatically initialized to one based on uninitialized variables

;the fact that the empty string uses an uninitialized variable)

; E_CORE_ERROR – Fatal error that occurs during the initialization process when PHP starts up

; E_CORE_WARNING – a warning (non-fatal error) that occurs during the initialization process when PHP starts up

; E_COMPILE_ERROR – Fatal compile-time error

; E_COMPILE_WARNING – compile-time warning (non-fatal error)

; E_USER_ERROR – user generated error message

; E_USER_WARNING – user generated warning message

; E_USER_NOTICE – reminder message generated by the user

Any number of the above options can be "or" connected (using OR or |), so that all required error levels can be reported.

For example, the following code turns off user-defined errors and warnings, performs certain operations, and then returns to the original error level: Example 1,

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

Example 2,

<?php
error_reporting(255);   // 列出所有提示
error_reporting(0);     // 不显示所有提示
error_reporting(7);     // 建议使用
?>
Copy after login

Usage reference of error_reporting() function in 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template