I believe many new php users, like me, are depressed when learning PHP. what is the @ (at) Mark? Once you download others' source code, you can see countless @
I believe many new php users, like me, have been depressed when learning PHP. @ (at) what is the mark?
Once you download other people's source code, you can see countless @ marks and start to think it is a comment. later, you will find that the @ statements will be executed. wondering, what is this mark .....
With the continuous development of learning, I finally understood it. this mark is similar to the "on error resume next" error in asp ". they play the same role. when the php interpreter encounters a statement starting with @, it will continue to execute subsequent statements regardless of whether the statement of the row is successfully executed, and no error will be reported. note that the @ (at) mark only works for the current row. I hope the @ (at) problem will be fixed here, for example. the following sentence certainly reports an error.
The error code example is as follows:
-
-
- $ SQL = mysql_connect (*);
- ?>
However, if we add the @ (at) mark, no error will be reported and the execution will continue.
The sample code is as follows:
-
-
- @ $ SQL = mysql_connect (*);
- Echo "I have been executing ";
- ?>
Continue to execute the following code.
The instance code is as follows:
- @ $ Page = $ _ GET ['Page']? Intval ($ _ GET ['Page']): 1;
This is the value of the page keyword obtained from the URL, such as "index. php? Page = 5 ", then $ page will get 5. however, if there is an error, such as "index. php "does not have the page keyword. if $ _ GET ['Page'] does not exist, an error is returned. if @ exists, this small error can be ignored.
The instance code is as follows:
- $ Conn = mysqli_conncet ("q", "w", "e", "r ");
In this case, the error message about database connection is entered.
The instance code is as follows:
- @ $ Conn = mysqli_conncet ("q", "w", "e", "r ");
If @ is added before $ conn, the error message cannot be output.