PHP pre-add at match @ Function Parse _php instance

Source: Internet
Author: User
Everyone in the PHP project, there are always some lines of code with the @ symbol, you know what it means? below to share in PHP the function of the pre-plus at in accordance with the role of @ Resolution

If you use it today, just remember it. In fact, it is the error control, even if an error occurs, ignore the error message, continue to execute the code below.

Copy the Code code as follows:
@ $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:
Copy the Code code as follows:
$conn = Mysqli_conncet ("Q", "W", "E", "R");

This will enter an error message about connecting to the database.

Copy the Code code as follows:
@ $conn = Mysqli_conncet ("Q", "W", "E", "R");

If the $conn is preceded by the @, you can not let him output the error message.

Here's a little bit of a note.

The above is the PHP pre-plus at in accordance with the role of @ resolution, I hope you like.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.