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):
Php global variables, which are defined by php global variables. Php global variables, php global variables define PHP global variables PHP pre-defines several Super global variables (superglobals), which means that they can use php global variables
Static function (modifier function, local variable, global variable)In the C language, the literal meaning of static can easily lead us astray. In fact, it has three functions.(1) first introduce the first and most important one: hiding.When we
What is a Hyper global variable
Many of the predefined variables in PHP are "hyper-global", which means they are available in all scopes of a script. There is no need to perform a global $variable in a function or method; You can access
The variables defined by global are global variables, so to speak, if a variable in a function is not a variable in PHP with the same name as the outside of the function, if we use global to define the same variable name in the function, then they
The role of the 1:php global variable is to define global variables, but this global variable is not applied to the entire site, but to the current page, including all files of include or require
$ a = 123 ;
function AA ()
{
PHP's resolution to the global variable is that global variables are defined globally, but this global variable is not applied to the entire site, but is applied to the current page, including all files of the include or require.
Cases
Twig template Get global variable method, twig template global variable
The example in this article describes how the twig template obtains global variables. Share to everyone for your reference, as follows:
In brief, Twig is a template engine that
PHP has a super global variable $globals that is not used by many people. Reasonable use of this variable can make the work more efficient, this article mainly analyzes the use of this super-global variable and the difference between $globals and
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.