This article explains the usage of PHP assignment by value and assignment by address. Share it with everyone for your reference. The details are as follows:
?
2 3 11 12
|
<🎜>$name = 'Simon'; //Assign a value to the variable $name (assignment by value)<🎜> <🎜>$name_b = $name; //Assign a value to variable $name_b (assignment by value)<🎜> <🎜>$addr = &$name; //Assign value to variable $addr (pass address assignment)<🎜> <🎜>$name = "Elaine"; //Change the value of $name<🎜> <🎜>echo $name; //Output $name, you will find that the value of $name has changed<🎜> <🎜>echo $name_b; //Output $name_b, you will find that the value of $name_b has not changed<🎜> <🎜>echo $addr; //Output $addr, you will find that the value of $addr has changed<🎜> <🎜>$addr = "Helen"; //Change the value of $addr<🎜> <🎜>echo $name; //Output $name, you will find that the value of $name has changed<🎜> <🎜>echo $addr; //Output $addr, you will find that the value of $addr has changed<🎜> <🎜>?> |