I generally don’t use PHP’s reference symbols when writing code. First of all, I don’t know how to use it. C language is used to get addresses, but there may be some differences in PHP. It is said to be a copy of a variable, or Just copy the same variable again, such as
$a=&$b;
Then variable a and variable b are completely equal, completely equivalent to $a=$b; so is it necessary to write $a=&$b? This may also take up more memory space
Some people like to write like this
function &f($arg1,..) {
//code body
}
I think writing like this has no practical effect. Generally, the reference operator is written in the parameters of the function:function f(&$x,&$y){
// Here is the operation of $ x and $ y, that is, assigning value to $ x and $ y.
// No need to use the RETURN statement
}
Then if function f is called, the calculated values of $x and $y can be obtained directly outside the function.
$total=array();
$total_data='';
echo $total_data; //The value of total_data calculated by the f function is output here
var_dump($total);//The value of total calculated by the f function is output here
The above is my personal opinion, I hope everyone can correct me.