Local and global variables in php. How can I understand the scope in php? next we will introduce the local variables: variables declared inside the function. Global variables: describes in detail how to understand the scope of variables declared outside the function in php. next we will introduce local variables: variables declared inside the function. Global variables: variables declared outside the function.
7.2.8 convert local variables to global variables
The code is as follows: |
|
$ A = 5; Function funcChangeValue () { Global $; $ A = 10; } FuncChangeValue (); Echo $; ?> Output 10 |
7.2.9 use of super global variable $ GLOBALR
The code is as follows: |
|
$ GLOBALS ['A'] = 5; Function funcChangeValue () { $ GLOBALS ['A'] = 10; } FuncChangeValue (); Echo $ GLOBALS ['A']; ?> Output 10 |
Bytes. Global variables: variables declared outside the function. for details...