Source of: /manual/en/language.variables.superglobals.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/reserved.variables.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'language.variables.superglobals.php',
1 => 'Superglobals',
),
'up' =>
array (
0 => 'reserved.variables.php',
1 => 'Predefined Variables',
),
'prev' =>
array (
0 => 'reserved.variables.php',
1 => 'Predefined Variables',
),
'next' =>
array (
0 => 'reserved.variables.globals.php',
1 => '$GLOBALS',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="language.variables.superglobals" class="refentry">
<div class="refnamediv">
<h1 class="refname">Superglobals</h1>
<p class="refpurpose"><span class="refname">Superglobals</span> — <span class="dc-title">Superglobals are built-in variables that are always available in all scopes</span></p>
</div>
<a name="language.variables.superglobals.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<p class="para">
Several predefined variables in PHP are "superglobals", which means they
are available in all scopes throughout a script. There is no need to do
<strong class="command">global $variable;</strong> to access them within functions
or methods.
</p>
<p class="para">
These superglobal variables are:
</p><ul class="simplelist">
<li class="member"><var class="varname"><a href="reserved.variables.globals.php" class="classname">$GLOBALS</a></var></li>
<li class="member"><var class="varname"><a href="reserved.variables.server.php" class="classname">$_SERVER</a></var></li>
<li class="member"><var class="varname"><a href="reserved.variables.get.php" class="classname">$_GET</a></var></li>
<li class="member"><var class="varname"><a href="reserved.variables.post.php" class="classname">$_POST</a></var></li>
<li class="member"><var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES</a></var></li>
<li class="member"><var class="varname"><a href="reserved.variables.cookies.php" class="classname">$_COOKIE</a></var></li>
<li class="member"><var class="varname"><a href="reserved.variables.session.php" class="classname">$_SESSION</a></var></li>
<li class="member"><var class="varname"><a href="reserved.variables.request.php" class="classname">$_REQUEST</a></var></li>
<li class="member"><var class="varname"><a href="reserved.variables.environment.php" class="classname">$_ENV</a></var></li>
</ul><p>
</p>
</div>
<a name="language.variables.superglobals.changelog"></a><div class="refsect1 changelog">
<h3 class="title">Changelog</h3>
<p class="para">
</p><table class="doctable informaltable">
<thead valign="middle">
<tr valign="middle">
<th>Version</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="middle" class="tbody">
<tr valign="middle">
<td align="left">4.1.0</td>
<td align="left">
Superglobals were introduced to PHP.
</td>
</tr>
</tbody>
</table>
<p>
</p>
</div>
<a name="language.variables.superglobals.notes"></a><div class="refsect1 notes">
<h3 class="title">Notes</h3>
<blockquote><p><b class="note">Note</b>:
<b>Variable availability</b><br />
By default, all of the superglobals are available but there are
directives that affect this availability. For further information, refer
to the documentation for
<a href="ini.core.php#ini.variables-order" class="link">variables_order</a>.
<br />
</p></blockquote>
<blockquote><p><b class="note">Note</b>:
<b>Dealing with register_globals</b><br />
If the deprecated <a href="ini.core.php#ini.register-globals" class="link">register_globals</a>
directive is set to <i>on</i> then the variables within will
also be made available in the global scope of the script. For example,
<var class="varname"><a href="reserved.variables.post.php" class="classname">$_POST['foo']</a></var> would also exist as <var class="varname">$foo</var>.
<br />
For related information, see the FAQ titled
"<a href="faq.using.php#faq.register-globals" class="link">How does register_globals affect me?</a>"
<br />
</p></blockquote>
<blockquote><p><b class="note">Note</b>:
<b>Variable variables</b><br />
Superglobals cannot be used as
<a href="language.variables.variable.php" class="link">variable variables</a>
inside functions or class methods.
<br />
</p></blockquote>
</div>
<a name="language.variables.superglobals.seealso"></a><div class="refsect1 seealso">
<h3 class="title">See Also</h3>
<p class="para">
</p><ul class="simplelist">
<li class="member"><a href="language.variables.scope.php" class="link">variable scope</a></li>
<li class="member">The <a href="ini.core.php#ini.variables-order" class="link">variables_order</a> directive</li>
<li class="member"><a href="book.filter.php" class="link">The filter extension</a></li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>