首页 > 代码库 > 哪个变量可以引用全局作用域中可用的全部变量

哪个变量可以引用全局作用域中可用的全部变量

w

http://php.net/manual/en/language.variables.superglobals.php

http://php.net/manual/zh/language.variables.superglobals.php

http://php.net/manual/zh/reserved.variables.globals.php

http://php.net/manual/en/reserved.variables.globals.php

Superglobals

Superglobals — Superglobals are built-in variables that are always available in all scopes

Several predefined variables in PHP are "superglobals", which means they are available in all scopes throughout a script. There is no need to do global $variable; to access them within functions or methods.

These superglobal variables are:

  • $GLOBALS
  • $_SERVER
  • $_GET
  • $_POST
  • $_FILES
  • $_COOKIE
  • $_SESSION
  • $_REQUEST
  • $_ENV

超全局变量 — 超全局变量是在全部作用域中始终可用的内置变量

说明

PHP 中的许多预定义变量都是“超全局的”,这意味着它们在一个脚本的全部作用域中都可用。在函数或方法中无需执行 global $variable; 就可以访问它们。

 

 

$GLOBALS

(PHP 4, PHP 5, PHP 7)

$GLOBALS — References all variables available in global scope

An associative array containing references to all variables which are currently defined in the global scope of the script. The variable names are the keys of the array.

$GLOBALS

$GLOBALS — 引用全局作用域中可用的全部变量

一个包含了全部变量的全局组合数组。变量的名字就是数组的键。

哪个变量可以引用全局作用域中可用的全部变量