Instructions on the use of the at @ symbol in php

Source: Internet
Author: User
I believe many new php users, like me, are depressed when learning PHP. what is the @ (at) Mark? Once you download others' source code, you can see countless @

I believe many new php users, like me, have been depressed when learning PHP. @ (at) what is the mark?

Once you download other people's source code, you can see countless @ marks and start to think it is a comment. later, you will find that the @ statements will be executed. wondering, what is this mark .....

With the continuous development of learning, I finally understood it. this mark is similar to the "on error resume next" error in asp ". they play the same role. when the php interpreter encounters a statement starting with @, it will continue to execute subsequent statements regardless of whether the statement of the row is successfully executed, and no error will be reported. note that the @ (at) mark only works for the current row. I hope the @ (at) problem will be fixed here, for example. the following sentence certainly reports an error.

The error code example is as follows:

  1.  
  2. $ SQL = mysql_connect (*);
  3. ?>

However, if we add the @ (at) mark, no error will be reported and the execution will continue.

The sample code is as follows:

  1.  
  2. @ $ SQL = mysql_connect (*);
  3. Echo "I have been executing ";
  4. ?>

Continue to execute the following code.

The instance code is as follows:

  1. @ $ Page = $ _ GET ['Page']? Intval ($ _ GET ['Page']): 1;

This is the value of the page keyword obtained from the URL, such as "index. php? Page = 5 ", then $ page will get 5. however, if there is an error, such as "index. php "does not have the page keyword. if $ _ GET ['Page'] does not exist, an error is returned. if @ exists, this small error can be ignored.

The instance code is as follows:

  1. $ Conn = mysqli_conncet ("q", "w", "e", "r ");
In this case, the error message about database connection is entered.

The instance code is as follows:

  1. @ $ Conn = mysqli_conncet ("q", "w", "e", "r ");
If @ is added before $ conn, the error message cannot be output.

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.