Use of PHP references


References are often used in programs. In order to share the same memory without the need for additional copies, when using references in the XXX environment, you need to pay attention to the following situations;
Use references in the input parameters of functions When calling, you cannot add & before the input parameter to reference it, but you can use the variable directly. At the same time, you must indicate that the input parameter comes from a reference when the function is defined, such as the following code:

$a = 1;
function ab(&$var){
    $var ++;
    return $var;
}
$b = ab($a) // 注意,此处不能使用 $b = ab(&$a)的方式;
echo $b.”/n”;
echo $a.”/n”;

At this time, $a and $b are both 2;

The special requirements for references in the XXX environment originate from allow_call_time_pass_reference in the php.ini file settings, the public version is On , so that & can be directly added to the front of the variable when calling the function for reference, but this method has been protested and may no longer be supported in future versions of PHP/Zend. The encouraged way to specify which parameters are passed by reference is in the function declaration. You are encouraged to try turning this option off (using off, it is off in all running environments of XXX) and confirm that your scripts still work properly to ensure that they can still work in future versions of the language.