The error control operator, as its name implies, is used to control error output. this control only shields error information and prevents it from being displayed. it does not actually solve the error. The method is simple, that is, add "@" before the wrong expression. Today, I will explain the"
Error Control Operator".
First, let's take a lookErrorWhat are the control operators?
The error control operator, as its name implies, is used to control error output. this control only shields error information and prevents it from being displayed. it does not actually solve the error.
The method is simple, that is, add "@" before the wrong expression.
You can use this operator to block unnecessary error messages when using some functions in a program, provided that this error message does not affect the running of the program. If errors that affect program operations are not recommended, it is not conducive to eliminating program errors.
Note that the "@" error controller cannot be placed before the function or class definition, or used in the condition structure. The "@" control operator is only valid for the expression. Simply put, if a value is obtained from a place, we can put @ in front of it. For example, place @ in front of variables, constants, and function calls.
Let's take a look at it.Use of error control operators
When we open a non-existent file, we use "@" to block the output of error messages.
When "@" is not used;
The following output is displayed:
However, when "@" is used. This error message will not appear. The implementation code is as follows.
In this way, no error information is output. of course, this error still exists, but cannot be seen.
The above example is a simple application of the "@" error control operator. In the next section, we will introduce the ternary operators in PHP operators in detail.
Recommended articles:
1. PHP operator (1) "arithmetic operator" example
2. PHP operator (2) "string operator"
3. PHP operator (3) "value assignment operator" example
4. PHP operator (4) "bit operator" example
5. PHP operator (5) "logical operator" example
6. PHP operator (6) "comparison operator" example
The above is the details of the PHP operator (7) "error control operator" instance. For more information, see other related articles in the first PHP community!