This article shares the differences between $globals and global in the hyper-global variables in PHP.
First, super global variable $globalsThere are many PHP hyper-global variables, such as the following are the Hyper global Variables (superglobal):
This article is about the difference between hyper-global variables $globals and Global in PHP.
One, super global variable $globalsThere are many PHP hyper-global variables, such as the following are super global variables (superglobal):$GLOBALS, $_
This can cause some problems, and some people may inadvertently change a global variable. Global variables in PHP must be declared as global when used in functions (note that the Global keyword is defined in the function to be useful).
The role of 1:
Most people will think that global and $globals[] are just different, but it's not, so let's take a look at what's the difference between them.
According to the official explanation,
$GLOBALS [' var '] is the external global variable $var
Many people think that global and $globals[] are just the differences in writing, but they are not.
According to the official explanation,
$GLOBALS [' var '] is an external global variable $var itself.
The global $var is a reference or pointer
This article will introduce in detail the global method of the global variable in PHP. the scope of the variable is the context defined by it (that is, its effective range ). Most PHP variables have only one separate range. This independent range
Does php support global variables? Can you define a global variable, assign it different values on different pages, and then call it. & Nbsp; for example, define var = 0 in. & nbsp; var = 1; & nbsp; includec. php in B. & nbsp; var = 2; & nbsp; Dec.
This article introduces the global method of global variables in PHP in detail. If you need to know how to use global functions, refer to this article.
The scope of a variable is the context defined by it (that is, its effective range ). Most PHP
Global variables: Variables defined in the main program (outside the function), can only be used in the main program, cannot be called inside the functionBackground: Solving the problem of calling global variables inside a functionWorkaround:1.
Use global variables in PHP and $globals[]
In PHP development projects, will inevitably use the global variables, such as some Web site configuration information, the whole station general, it can be set in one place, and then multiple places to
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.