PHP Pass value Assignment and reference assignment notes

Source: Internet
Author: User

Value Assignment: The value of the argument is assigned to the row parameter, and the modification of the row parameter does not affect the value of the argument.
For example: root copy is the same. For example, I have one? H House, I give you building materials, you built a house that is identical to my house, what you do in your house will not affect me, what I do in my house will not affect you, independent of each other.

The code is as follows Copy Code

$AA = 1;
$BB = 2;
$AA = $BB//$AA and $BB are irrelevant to each other.
$AA = 3;
Echo $aa, '--', $BB//Output 3--2

Reference Assignment: when the actual address passes the parameter pass, the row and the arguments are the same object, but their names are different. Changes to a row parameter affect the value of the argument
For example: It reminds me of the pointer to learning C when I was in college. For example, I have one? H House, I give you a key, we all two can enter this House, what you do in the House will affect me.

  code is as follows copy code

$aa =1;
$BB = 2;
$aa =& $BB//$BB references to $AA, regardless of $aa, or $bb change to each other
$aa =3;
Echo $aa, '--', $BB;/output 3--3

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.