Home >Backend Development >PHP Tutorial >Introduction to PHP superglobals (Superglobals), global superglobals_PHP tutorial
Overview
I want to build a public platform for WeChat. After reading the sample code for website access provided by WeChat official, I found that there is a problem that seems to be half-understood, which is to use $_GET directly in the class. After carefully checking the knowledge in this area, I found that the basic knowledge of this part of PHP is not very reliable.
Scope of variable
When it comes to PHP’s superglobal array, we have to talk about the scope of variables. The scope of variables is a concept that exists in any programming language and must be mastered. Regarding the variable scope in PHP, I won’t say more here. You can check the information yourself.
Super global array
Super global arrays are specially defined array variables in PHP. They are called super global arrays because these arrays can be accessed anywhere in the script and in any scope, such as functions, classes, files, etc.
Superglobal arrays in PHP include the following:
Copy code The code is as follows:
$GLOBALS
$_SERVER
$_GET
$_POST
$_REQUEST
$_COOKIE
$_SESSION
$_FILES
$_ENV
Attention
One thing to note is the difference between global variables and superglobal arrays in PHP. Global variables cannot be directly accessed in a class.
Summary
In the future, you should pay more attention to basic knowledge and solve your questions in a timely manner.