1.Reference global variables
Method1
1 <? PHP
2 $ Var = 0;
3 function test ($ index)
4 {
5 global $ var;
6 $ Var = $ var + 1;
7 Echo "the". $ index. "Number is". $ var. "<br> ";
8}
9 Test (1 );
10 test (2)
11?>
Method2
1 <? PHP
2 $ Var = 0;
3 function test ($ index)
4 {
5
6 $ globals ["Var"] = $ globals ["Var"] + 1;
7 Echo "the". $ index. "Number is". $ globals ["Var"]. "<br> ";
8}
9 test (1 );
10 test (2)
11?>
2. Define Constants
Bool define (string name, mixed value [, bool case_insensitive])
Name is the constant name and value is the constant value. Case_insensitive] Is case sensitive. The default value is sensitive. For example:
1 <? PHP
2 define ("constant", "Hello world .");
3 Echo constant; // outputs "Hello world ."
4 echo constant; // outputs "constant" and issues a notice.
Original article:
Http://www.cnblogs.com/confach/articles/470492.html