illustrate
1. Reference assignment. Using this assignment method means that the new variable refers to the original variable, and changing one will affect the other.
In this process, the copy operation is omitted, and all such assignment methods are more efficient;
2. Only variables with names can be assigned values, and the unset() function releases one of them without affecting the other.
Example
<?php $foo = 'Bob'; // Assign the string 'Bob' to $foo $bar = &$foo; // Assign the reference of traversing $foo to variable $foo $bar = "My name is Tom"; // Change the value of variable $bar echo "$bar"; // Output My name is Tom echo "$foo"; // Also output My name is Tom $foo = "Your name is Jack"; // Change the value of variable $foo echo "$foo"; // The output is Your name is Jack echo "$bar"; // The same output is Your name is Jack
The above is the reference assignment use of PHP variables. I hope it will be helpful to everyone. More PHP learning guide: source code network
Recommended operating system: windows7 system, PHP5.6, DELL G3 computer