The full name of global data in PHP is superglobal array or superglobal variable, which is a specially defined array variable in PHP; superglobal array can be accessed anywhere in the script and in any scope, superglobal Array variables are built-in variables that are always available in all scopes.
The operating environment of this article: Windows 10 system, PHP version 8.1, Dell G3 computer
What is the meaning of global array in php
php The full name of the global array is "super global array" or "super global variable". It is a specially defined array variable in PHP. It is called super global array because these arrays can be used anywhere in the script and in any scope. Access, such as functions, classes, files, etc.
Super global array variables are built-in variables that are always available in all scopes
Super global arrays in PHP include the following:
$GLOBALS
A global combined array containing all variables. The name of the variable is the key of the array.
Use var_dump($GLOBALS) to print, you can see that $GLOBALS is a global combination array that contains all.
As of PHP 8.1.0, $GLOBALS is now a read-only copy of the global symbol table. That is, global variables cannot be modified through copies. In previous versions, $GLOBALS arrays and PHP arrays generally behaved differently when passing values, and global variables could be modified via copies.
Before PHP 8.1.0:
$a = 1;$globals = $GLOBALS; // 表面意义的按值复制$globals['a'] = 2; // $GLOBALS['a'] 的值也相应修改 var_dump($a);//运行结果: int(2)
From PHP 8.1.0:
$a = 1;$globals = $GLOBALS; //表面意义的按值复制$globals['a'] = 2; // $GLOBALS['a'] 的值不会改变(不再修改 $a) var_dump($a);//运行结果: int(1)
To restore the previous behavior, iterate over its copy and assign each property back $GLOBALS:
foreach ($globals as $key => $value) { $GLOBALS[$key] = $value;}
$_SERVER
$_SERVER - Server and execution environment information. $_SERVER is an array containing information such as header, path, and script locations. The items in this array are created by the web server.
$_GET
An array of variables passed to the current script via URL parameters. Note: This array is not only effective for requests whose method is GET, but for all requests with query string.
$_POST
The predefined $_POST variable is used to collect data from forms with method="post" value.
When the Content-Type of the HTTP POST request is application/x-www-form-urlencoded or multipart/form-data, the variables will be passed into the current script in the form of an associative array.
Information sent from a form with the POST method is invisible to anyone (will not be displayed in the browser's address bar), and there is no limit on the amount of information sent.
Note: However, by default, the maximum amount of information sent by the POST method is 8 MB (can be changed by setting post_max_size in the php.ini file).
$_REQUEST
Contains an array of $_GET, $_POST and $_COOKIE by default. Due to security issues, it is recommended to avoid using $_REQUEST.
$_COOKIE
An array of variables passed to the current script through HTTP Cookies.
$_SESSION
An array of SESSION variables available to the current script.
$_FILES
An array of projects uploaded to the current script via HTTP POST.
$_ENV
An array of variables passed to the current script through the environment.
These variables are imported from the PHP parser's running environment into the PHP global namespace. Many are provided by shells that support PHP running, and different systems are likely to run different kinds of shells, so a definitive list is impossible. Please check your shell documentation for a list of defined environment variables.
Other environment variables include CGI variables, regardless of whether PHP is running as a server module or a CGI processor.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What does global array mean in php. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software