Home >Backend Development >PHP Tutorial >Introduction to PHP superglobals (Superglobals), global superglobals_PHP tutorial

Introduction to PHP superglobals (Superglobals), global superglobals_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:48:04916browse

Introduction to PHP superglobals, global superglobals

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1024913.htmlTechArticleIntroduction to PHP superglobals (Superglobals), overview of global superglobals I want to build a WeChat public platform, and read the WeChat official I found a problem with the sample code for accessing the URL given...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn