Detailed explanation of php reference assignment

怪我咯
Release: 2023-03-14 06:42:01
Original
1412 people have browsed it

Reference assignment is to copy the reference of variable (the new reference still points to the original value). After the parameters are truly passed by address, the line parameters and actual parameters are the same object, but their names are different. Modification of the line parameters will affect the value of the actual parameters

The & symbol indicates that the value is assigned by reference during the assignment process.

For example: It reminds me of the pointers I learnedC language when I was in college, and it feels almost the same. For example, I have a house. If I give you a key, both of us can enter the house. Whatever you do in the house will affect me.

table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7">   代码如下 复制代码   $aa=1;
$bb=2;
$aa=&$bb;//$bb引用内容指向$aa,不管$aa,或者$bb发生变化,彼此都会变化
$aa=3;
echo $aa,'--',$bb;//输出3--3
    
Copy after login

The above is the detailed content of Detailed explanation of php reference assignment. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!