The code is as follows
<?php
$x=5;
$y=10;
function myTest()
{
global $x,$y;
$y=$x $y;
}
myTest();
echo $y; // Output 15
?>
ringa_lee2018-07-25 21:43:33
The answer is 10, that’s right. First of all, you have to understand the definition of the keyword global. There is a big difference between global and $GLOBALS. $GLOBALS defines variables as global variables. If it is defined by $GLOBALS, the result will be natural. It is 15, and global is used as a reference. Please note that the reference is not a pointer, and it cannot ultimately change the result of $x or $y!