For a reference question, please help me! Thank you & lt ;? Php & nbsp; function & nbsp; demo (& amp; $ a, & nbsp; & amp; $ B) & nbsp ;{& nbsp; $ a & nbsp; & amp; & nbsp; $ B; & nbsp ;}& nbsp; $ a & nbsp; 1; & nbsp; $ B & nbsp; 2; & nbsp; demo ($ a, for a reference question, please help me! Thank you.
Function demo (& $ a, & $ B) {$ a = & $ B ;}
$ A = 1;
$ B = 2;
Demo ($ a, $ B );
$ B = 3;
Print $;
?>
Detailed source reference: http://www.jb51.net/article/22508.htm
What I saw when I read a reference article,
The result is 2,
I think the result is 3,
The result after running is 1.
I am a beginner in php. I don't quite understand its reference parameter passing ,,,,,,
------ Solution --------------------
For ease of description, the parameter name is changed
function demo(&$x, &$y) {
$x =& $y;
}
$a = 1;
$b = 2;
demo($a, $b);
print $a;
& $ X is another form of global $
Therefore
$ X = & $ y;
Yes
Global $;
$ A = & $ y;
Hope you can understand this.
The manual includes:
If a global variable is assigned to a reference within a function, the reference is only visible within the function.
I won't talk about anything anymore.