Explanation of Global keyword reference in PHP Global variables

Source: Internet
Author: User
This article will give you a brief introduction to the reference to the Global keyword of the PHP Global variable. although the comments are short compared with the articles, the principles are quite clear and simple.

This article will give you a brief introduction to the Global keyword reference of PHP Global variables. although the comments are short compared with the articles, the principles are quite clear and easy to understand, especially for those who have some language basics, it is worth summarizing. don't close the customs. start with the question:

$ GLOBALS reference to the PHP manual:

Global variable: $ GLOBALS

Note: $ GLOBALS is applicable to PHP 3.0.0 and later versions.

An array composed of all defined global variables. the variable name is the index of the array.

This is a "superglobal", or it can be described as an automatic global variable. that is to say, $ var1 and $ GLOBALS ['var1'] in the above code refer to the same variable, rather than two different variables!

For example, the instance code is as follows:

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.