84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
$x=5;
$y=6;
function test(){
global $x,$y;
$y= $x $y;
}
test();
echo $y;
?>
body>
After execution, the result is 6, shouldn’t it be 11? I checked that $x has no value
You only used the value of the global variable in the method, and the value of the global variable did not change.
Use the $GLOBAL super global function to print the data and you will know how much the data is
//是可以正常显示11呀,不行你复制本地测试一下看看 $x=5; $y=6; function test(){ global $x,$y; $y=$x+$y; //11= 5 + 6 } test(); echo $x; //5 echo ""; echo $y; //11
You only used the value of the global variable in the method, and the value of the global variable did not change.
Use the $GLOBAL super global function to print the data and you will know how much the data is