Introduction to PHP Superglobals

Source: Internet
Author: User
This article mainly introduces PHP Superglobals. This article describes the overview, scope of variables, ultra-global arrays, and precautions. For more information, see

This article mainly introduces PHP Superglobals. This article describes the overview, scope of variables, ultra-global arrays, and precautions. For more information, see

Overview

I want to build a public platform and read the sample code for accessing the official website. I found a problem that seems to have always been half-known, $ _ GET is directly used in the class. I carefully checked my knowledge about this and found that the basic knowledge of PHP is not very reliable.

Variable Scope

When it comes to PHP's ultra-global array, the scope of the variable cannot be left alone. The scope of variables is a concept in any programming language and must be mastered. We will not talk about the variable scope in PHP. You can view the information on your own.

Ultra-Global Array

A hyper-global array is an array variable defined in PHP. It is called a hyper-Global Array because these arrays can be accessed anywhere in the script and in any scope, such as functions, classes, and files.

The hyper-Global Array in PHP includes the following:

The Code is as follows:


$ GLOBALS
$ _ SERVER
$ _ GET
$ _ POST
$ _ REQUEST
$ _ COOKIE
$ _ SESSION
$ _ FILES
$ _ ENV

Note:

Note the differences between global variables and global arrays in PHP. You cannot directly access global variables in the class.

Summary

In the future, we will pay more attention to the basic knowledge and promptly resolve our questions.

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.