In PHP, the at added before "@file_exists", which is the "@" symbol, means "error control operator"; the error control operator is used to control error output and can express the following operator Masking the error message and preventing it from being displayed does not really solve the error.
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.
@ is the "error control operator" in the PHP operator.
Add the @ symbol in front of the file_exists function to disable the error message output of this function, so that the information when the file does not exist will only be output by the program.
First of all, let’s understand what the error control operator does?
The error control operator, as its name implies, is used to control error output. This control only blocks the error information and prevents it from being displayed. It does not really solve the error.
The method is very simple, just add "@" before the wrong expression.
When unnecessary error messages often appear when using certain functions in a program, you can use this operator to shield them, provided that the error message does not affect the running of the program. If there are some errors that affect program operation, we do not recommend using error control characters, as this is not conducive to eliminating program errors.
There is something to note here. Our "@" error control character cannot be placed before the definition of a function or class, nor can it be used in conditional structures, etc. The "@" control character is only valid for expressions.
To put it simply: if we get a value from a place, we can put @ in front of it. For example, put @ in front of variables, constants, and function calls.
Let’s take a look at an example of using the error control operator. When we open a file that does not exist, use “@” to block it
Recommended learning: "PHP Video Tutorial》
The above is the detailed content of What does the '@' added in front of @file_exists in php mean?. For more information, please follow other related articles on the PHP Chinese website!