error_reporting() sets the error reporting level of PHP

WBOY
Release: 2016-08-04 09:21:12
Original
1232 people have browsed it

error_reporting(E_ALL ^ ​​E_NOTICE ^ E_STRICT ^ E_DEPRECATED);
Brothers, help me explain what this line of code means and what error level to set,

Reply content:

error_reporting(E_ALL ^ ​​E_NOTICE ^ E_STRICT ^ E_DEPRECATED);
Brothers, help me explain what this line of code means and what error level to set,

Check the official PHP documentation to know: error_reporting
The above code means: all errors except E_NOTICE E_SCRICT E_DEPRECATED are reported.
E_ALL ^ ​​E_NOTICE ^ E_STRICT ^ E_DEPRECATED This is a continuous XOR operation.
E_ALL E_NOTICE E_STRICT E_DEPRECATED These are constants, and the corresponding binary numbers are roughly as follows

<code>E_NOTICE 00001 
E_STRICT 00010
E_DEPRECATED 00100
E_ALL 11111
</code>
Copy after login

After performing the XOR operation, it is equivalent to turning the same ones into 0 and the different ones into 1. In other words, the result obtained is that E_ALL excludes those that perform the XOR operation.
The values ​​corresponding to the above constants are purely fictitious. You can try to print them out to see what they are.
Similarly, you can also use methods such as E_NOTICE | E_STRICT to set multiple levels for reporting. The principle is that after the or operation, if there is 1, it is 1, and if there are all 0, it is 0

What this means is: output all types of errors (E_ALL), but exclude E_NOTICE, E_STRICT, and E_DEPRECATED.

A bit operation technique is used here, because E_ALL is an all-1 number, and E_NOTICE, E_STRICT, and E_DEPRECATED are all single-1 numbers. These are XORed to form a log-level number that excludes these items. .

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template