I believe a lot of PHP and I like the new students in the study of PHP and I like, are depressed over this problem. @ (at) What exactly does this sign do?
Once, download other people's source view, see Countless @ marks, began to think is a comment, and later found that the statement behind the @ will also be executed. Wondering, what is the mark doing?
With the continuous deepening of learning, it is finally clear. The function of this notation is somewhat similar to the Ignore error "On Error Resume Next" in ASP. Their role is the same, when the PHP interpreter encounters the statement at the beginning of the @, regardless of whether our statement is successful, the subsequent statements will continue to execute, without error. However, it is important to note that the @ (at) tick only works on the current line.
I hope the question about @ is here.
eg. The following statement must be an error.
Error code
| The code is as follows |
Copy Code |
$sql = mysql_connect (*); ?> |
However, if we add the @ (at) Mark, we will not get an error and continue to execute.
No error code
| The code is as follows |
Copy Code |
@ $sql = mysql_connect (*); echo "I have been executing"; ?> |
Continue executing the code below.
| The code is as follows |
Copy Code |
@ $page =$_get[' page ']?intval ($_get[' page '): 1; |
This is the value from the URL to get the page keyword, such as "index.php?page=5", then the $page will be taken to 5.
But if there is an error, such as "index.php" after the page keyword, if you go to fetch $_get[' page ' does not exist will be an error, then there is @ can ignore this small error.
Another example:
| The code is as follows |
Copy Code |
$conn = Mysqli_conncet ("Q", "W", "E", "R"); |
This will enter an error message about connecting to the database.
| The code is as follows |
Copy Code |
@ $conn = Mysqli_conncet ("Q", "W", "E", "R"); |
If the $conn is preceded by the @, you can not let him output the error message.
http://www.bkjia.com/PHPjc/628691.html www.bkjia.com true http://www.bkjia.com/PHPjc/628691.html techarticle I believe a lot of PHP and I like the new students in the study of PHP and I like, are depressed over this problem. @ (at) What exactly does this sign do? Once, download other people's Source view, ...