Questions about the PHP reference address changing the value of the variable

Source: Internet
Author: User
  1. $foo = ' Bob '; Assign ' Bob ' to $foo
  2. $bar = & $foo; by $bar Reference $foo
  3. echo $foo. '
    ';
  4. $bar = "My name is $bar"; modifying $bar variables
  5. echo $bar. '
    ';
  6. echo $foo. '
    '; The value of the $foo is also modified
  7. ?>
Copy Code

Output: bobmy name is bobmy name is Bob

You can see that the original value has been modified, it occurs after the reference and is assigned, but the original variable is not changed until the value is assigned. Articles you may be interested in: A detailed introduction to PHP reference values through an instance to understand the difference between the value and the reference in PHP by example, see the efficiency of PHP address reference in PHP reference, "&" explanation

  • 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.