Scope refers to a range in which a variable can be used or visible in a script, and PHP has 6 basic scoping rules. 1. Built-in super global variables can be used and visible anywhere in the script. 2. Constants, once declared, can be visible globally, that is, they can be used both inside and outside the function. 3. Global variables declared in a script are visible throughout the script, but not within the function. 4. Variables used inside the function are declared as global variables, and their names are consistent with the global variable name. 5. A variable that is created and declared static inside a function cannot be visible outside of a function, but it can be persisted during multiple executions of a function. 6. A variable created inside a function is local to the function, and the variable does not exist when the function terminates. $_get and $_post arrays, as well as some other special variables, have their own scope rules. These are called super global variables that can be used and visible anywhere, including internal and external functions.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.