$A="hello";
function print_a(){
$A="php&mysql";
global $A;
$A="mytest";
echo $A;
}
echo $A;
echo "
";
print_a();
echo "
";
echo $A;
?>
Output result:
hello
mytest
mytest
I was a little confused at first, but this program and the output clearly illustrate what global.
In the function definition, after declaring global, the variable becomes global. Of course, even if a local variable with the same name has been defined in the function, "it" is no longer used, and it becomes a reference to the previously defined variable. .