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, read the sample code for accessing the official website, and find that there is 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.