What are the error control operators in php
This article will explain in detail what the error control operators in php are, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
The error control operator in php is "@", and any error messages that may be generated by an PHP expression will be ignored. The "@" operator is only valid for expressions, it can precede variables, functions, include calls, constants, and so on, but not before the definition of a function or class.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php error control operator: @
PHP supports the use of the error control operator @. Any error messages that may be generated by an PHP expression will be ignored before it is placed.
If you set a custom error handler with set_error_handler (), the error handler will still be called, and if @ is used before the error statement, the error handler will return 0.
It is important to note that the @ operator is valid only for expressions. To put it simply, if you can get a value from somewhere, you can precede it with the @ operator. For example, you can use the @ operator before variables, functions, include calls, constants, and so on, but it cannot be placed before the definition of a function or class, nor can it be used before conditional structures such as if and foreach statements.
The @ operator is also valid for serious errors that can cause the program to terminate, which means that if @ is used to suppress the error message before a function call that does not exist or typed the wrong letter, the program will die there without any hint.
[example] use the @ error operator to mask errors in the code.
The running results are as follows:
Database connection failed! On the error control operators in php which are shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.