<?php
$x=10;
$y=20;
function test(){
global $x,$y; //Use global keyword
$y=$x $y;
}
test();
echo $y;
##<? php
$x=5;
$y=10;
function myTest()
{
$GLOBALS['y']=$GLOBALS['x'] $GLOBALS['y'];
}
myTest();
echo $y;
?>
Are these two writing methods the same? Why is the returned result one 30 global $y
Only the first $y is a global variable