- Scope
The area to which the variable can be accessed.
JS in scope:
Global scope: can be used anywhere (outside the function and inside the function)
Local scope: Can only be used inside a function
PHP also has two scopes: global scope and local scope
Global scope: can only be used outside the function, external cannot access the internal
Local scope: Can only be used inside a function, internal cannot access external
Global scope refers to a variable defined outside a function, and a local scope refers to a variable defined inside a function
A. You can use $globals[' global scope variable ' in local scope to access the global scope
B. PHP also provides a keyword: global
Global is the address of the variable of the global scope, replicates it, and creates a new variable name with the same name within the local scope, assigning the external address to the local variable.
Syntax: global variable name;
Variable name = value;
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above introduces PHP learning 2, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.