What does global array mean in php
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!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.
