Adding at in front of PHP is in line with the analysis of the role of @

高洛峰
Release: 2023-03-04 16:50:01
Original
1083 people have browsed it

When everyone is working on PHP projects, they always add the @ symbol before some lines of code. Does everyone know what it means? Let me share with you the analysis of the function of adding at before the function 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 following code will continue to be executed.

@$page=$_GET['page']?intval($_GET['page']):1;
Copy after login

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", and if $_GET['page'] does not exist, an error will be reported. If there is @, you can ignore this small error. .

Another example:

$conn = mysqli_conncet("q","w","e","r");
Copy after login

This will input error information about connecting to the database.

@$conn = mysqli_conncet("q","w","e","r");
Copy after login

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.

For more relevant articles on the analysis of the role of adding at in front of PHP, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!