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 ignore error "on error resume next" 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 applies to the current row.
I hope that the @ (at) issue will be fixed here.
Eg. The following sentence must report an error
Error Code
The Code is as follows: |
Copy code |
<? Php $ SQL = mysql_connect (*); ?> |
However, if we add the @ (at) Mark, no error will be reported and the execution will continue.
No error code
The Code is as follows: |
Copy code |
<? Php @ $ SQL = mysql_connect (*); Echo "I have been executing "; ?> |
Continue to execute the following code.
The Code is as follows: |
Copy code |
@ $ 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 ", $ 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 @ is returned, this small error can be ignored.
For example:
The Code is as follows: |
Copy code |
$ Conn = mysqli_conncet ("q", "w", "e", "r "); |
In this case, an error message is entered about database connection.
The Code is as follows: |
Copy code |
@ $ Conn = mysqli_conncet ("q", "w", "e", "r "); |
If @ is added before $ conn, the error message will not be output.