PHP quote trap

Source: Internet
Author: User
PHP reference Trap 1. & nbsp; $ a333; & nbsp; $ c & amp; $ a; & nbsp; $ d888; & nbsp; & nbsp; $ c & amp; $ d; & nbsp; echo $ c; & nbsp; echo $ a PHP reference trap
1. $ a = '000000 ';
$ C = & $;
$ D = '000000 ';
$ C = & $ d;
Echo $ c;
Echo $;

2. $ a = '000000 ';
$ C = & $;
$ D = '000000 ';
$ C = $ d;
Echo $ c;
Echo $;

In the fourth row, $ c = $ d and $ c = & $ d lead to completely different results.
$ C = $ d. Because $ c is a reference of $ a, the values of $ c and $ a will change to 888,
However, $ c = & $ d indicates that $ c has changed to a reference of $ d. It has nothing to do with $ a. Therefore, the value of $ a is still 333.
Note that referencing is just an alias, not a pointer.
In fact, it is similar to a Unix hard connection.
Http://www.php.net/manual/zh/language.references.whatare.php

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.