PHP parameters reference
In the variable function, we learned the reference to the variable, let's review the knowledge:
$a = 10;
$b = &$a;
$a = 100;
In the variable section of the appeal knowledge point, the variable reference is described, meaning that the variables $a and $b point to the same storage location to store the value.
The parameter reference of the function is also the meaning of pointing the formal parameters and arguments to the same position. If the formal parameter changes within the body of the function, the value of the actual parameter also changes. Let's take a look at the experiment:
$foo = 100;
//Note: the ampersand is added before $n
$n = 10;
Return $n + $n;
//You will get the value of $foo to become 10
In the above example, we found that the argument is $foo. When the demo is called, let $foo and $n point to the same storage area when the value of $n changes. Then the value of $foo also changes.