: This article mainly introduces the meaning and function of PHPglobal. if you are interested in the PHP Tutorial, you can refer to it. They all say that not writing an article is not a technical expert. next! To record the growth history of my Cainiao!
The scope of variables is something that every programmer must consider, but it is very different from C ++ in PHP! For example, if a function has the same internal and external variable names but cannot be overwritten, you must use global to reference the variables outside the function. Next, view the following demo:
$ Num = 10;
Function test (){
$ Num = $ num * 10;
}
Test ();
Echo $ num;
Output 10.
$ Num = 10;
Function test (){
Global $ num;
$ Num = $ num * 10;
}
Test ();
Echo $ num;
100 output. It's not difficult to program. let's try it out.
The above introduces the meaning and functions of PHP global, including some content, and hopes to help those who are interested in PHP tutorials.