When everyone is doing PHP projects, they always add the @ symbol in front of some lines of code. Everyone knows what it means. ? Let me share with you the analysis of the role of adding at before functions in PHP to match @
I used it today, so just remember it. In fact, it is an error control character. Even if an error occurs, the error message will be ignored and the code below will continue to be executed.
Copy code The code is as follows:
@$page=$_GET['page']?intval($_GET['page']):1;
This sentence is to get the value of the page keyword from the URL, such as "index.php?page=5", then $page will get 5.
But if there is an error, for example, there is no page keyword after "index.php", if you go to get $_GET['page'] does not exist, an error will be reported, this Sometimes @ can ignore this small mistake.
Another example:
Copy code The code is as follows:
$conn = mysqli_conncet("q","w","e","r");
This will input error information about connecting to the database.
Copy code The code is as follows:
@$conn = mysqli_conncet("q","w","e","r");
If you add @ in front of $conn, you can prevent it from outputting error messages.
Just jot it down here.
The above is the analysis of the function of adding at in front of PHP to comply with @. I hope you like it.