Home >Backend Development >PHP Tutorial >Adding at in front of PHP is in line with the function analysis of @, phpat_PHP tutorial

Adding at in front of PHP is in line with the function analysis of @, phpat_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:45:22849browse

Adding at in front of PHP is in line with the function analysis of @, phpat

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1041334.htmlTechArticlePHP Adding at in front of it conforms to the function analysis of @, phpat When everyone is doing PHP projects, there are always some lines of code before them Adding the @ symbol, does everyone know what it means? Let me share with you the functions in PHP...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn