php super global variables

巴扎黑
Release: 2016-11-21 09:28:45
Original
855 people have browsed it

Many predefined variables in PHP are "superglobal", which means they are available throughout the entire scope of a script. They can be accessed within a function or method without executing global $variable;.
These super global variables are:
$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION

$GLOBALS This kind of global variable is used in any PHP script Positional access to global variables (either from a function or method).
PHP stores all global variables in an array named $GLOBALS[index]. The name of the variable is the key of the array.

<?php 
$x = 75; 
$y = 25;
 
function addition() { 
  $GLOBALS[&#39;z&#39;] = $GLOBALS[&#39;x&#39;] + $GLOBALS[&#39;y&#39;]; 
}
 
addition(); 
echo $z; 
?>
Copy after login


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template