A reference to the PHP variable and a reference to the function are put back
A reference to a variable
$a = "ABC";
$b =& $a;
echo $a;//output here: ABC
echo $b;//output here: ABC
$b = "EFG";
echo $a;//The value of $ A here becomes EFG so the output EFG
echo $b;//Output EFG here
A reference to the function returns
function &test ()
{
Static $b =0;//declares a statically engineered variable
$b = $b +1;
Echo $b;
return $b;
}
$a =test ();//This statement outputs a value of $b of 1
$a = 5;
$a =test ();//This statement outputs a value of $b of 2
$a =&test ();//This statement outputs a value of $b of 3
$a = 5;
$a =test ();//This statement outputs a value of $b of 6
$a =&test () calls the function, and his role is to point the memory address of the $b variable in the return $b to the same place as the memory address of the $ A variable
That produces the equivalent effect ($a =& $b;) So changing the value of $ A also changes the value of the $b so that it executes the
$a =&test ();
$a = 5;
Later, the value of the $b becomes 5
References to PHP variables and references to functions