The usage difference between global and $ GLOBALS [] in php. In php, global and $ GLOBALS [] are common global variables. let's take a look at a simple example to differentiate the usage of global and $ GLOBALS. According to the official explanation: 1. in $ php, global and $ GLOBALS [] are common global variables. let's look at a simple example to differentiate the usage of global and $ GLOBALS.
According to the official explanation:
1. $ GLOBALS ['var'] is an external global variable.
| The code is as follows: |
|
$ Var1 = 1; Function test (){ Unset ($ GLOBALS ['var1']); } Test (); Echo $ var1; ?> |
2. global $ var is an external reference or pointer with the same name as $ var.
| The code is as follows: |
|
$ GlobalStr = '. com '; Function globalTest (){ Global $ globalStr; $ GlobalStr = 'coderbolg '. $ globalStr; Unset ($ globalStr ); } GlobalTest (); Echo $ globalStr; // input: coderbolg.com
|
Bytes. According to the official explanation: 1. $...