Php global .? Php $ Ahello; functionprint_a () {$ Aphpmysql; global $ A; $ Amytest; echo $ A;} echo $ A; echobr; print_a (); echobr; echo $ ;? Output result: hellomytestmytest has a point at the beginning.
$ A = "hello ";
Function print_a (){
$ A = "php & mysql ";
Global $;
$ A = "mytest ";
Echo $;
}
Echo $;
Echo"
";
Print_a ();
Echo"
";
Echo $;
?>
Output result:
Hello
Mytest
Mytest
At first, I had some doubts. However, this program and the output results clearly explain what is going on in global.
In function definition, after global is declared, the variable is global. of course, even if the function has defined a local variable with the same name, it cannot be used, instead, it is referenced in the previous definition.
From Liujie
Http://www.bkjia.com/PHPjc/478330.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478330.htmlTechArticle? Php $ A = hello; function print_a () {$ A = phpmysql; global $ A; $ A = mytest; echo $ A;} echo $ A; echo br; print_a (); echo br; echo $ ;? Output result: hello mytest start with a dot...