/    Sign up×
Community /Pin to ProfileBookmark

Which Are SuperGlobals ? Give Your List!

Folks,

I don’t understand this.
Can you list all the SuperGlobals you know ?
This tutorial:
https://www.w3schools.com/php/php_superglobals.asp
lists SuperGlobals like so:

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

Note that, there is no “$_PHP_SELF” because according to that tutorial, the category is $_SERVER and it’s subcategory is “$_PHP_SELF”.
But the following tutorial sees differently and list “$_
PHP_SELF” beside $_SERVER as a SuperGlobal.
https://www.tutorialspoint.com/php/php_predefined_variables.htm
Like so:


————————-

**1

$GLOBALS**

Contains a reference to every variable which is currently available within the global scope of the script. The keys of this array are the names of the global variables.
**2

$_SERVER**

This is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these. See next section for a complete list of all the SERVER variables.
**3

$_GET**

An associative array of variables passed to the current script via the HTTP GET method.
**4

$_POST**

An associative array of variables passed to the current script via the HTTP POST method.
**5

$_FILES**

An associative array of items uploaded to the current script via the HTTP POST method.
**6

$_REQUEST**

An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE.
**7

$_COOKIE**

An associative array of variables passed to the current script via HTTP cookies.
**8

$_SESSION**

An associative array containing session variables available to the current script.
**9

$_PHP_SELF**

A string containing PHP script file name in which it is called.
**10

$php_errormsg**

$php_errormsg is a variable containing the text of the last error message generated by PHP.
—————————–

Note that, the 2nd tutorial link doesn’t list the SuperGlobal “$_ENV”. Why ?
And the 1st tutorial doesn’t list the SuperGlobal “$php_errormsg”. Why ?
So, which tutorial correct ?
That is why I asked, you list all the SuperGlobals you know.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@developer_webauthorApr 14.2021 — Folkies,

I didn't know about the $_COOKIES here, I'm afraid:

**6

$_REQUEST

An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE.**

Anyway, if $_COOKIE is included then why not the $_SESSION array too ?
Copy linkTweet thisAlerts:
@developer_webauthorApr 14.2021 — Folks,

Can you show me code sample of this one ?

**10

$php_errormsg

$php_errormsg is a variable containing the text of the last error message generated by PHP.**

Tutorial didn't show it:

https://www.tutorialspoint.com/php/php_predefined_variables.htm
Copy linkTweet thisAlerts:
@NogDogApr 14.2021 — Hey, look, they're actually listed in the manual: https://www.php.net/manual/en/language.variables.superglobals (Who would've thought so? ;) )

> @developer_web#1630325 Anyway, if $COOKIE is included then why not the $SESSION array too ?

Because $_SESSION data is not part of the HTTP request.
Copy linkTweet thisAlerts:
@developer_webauthorApr 15.2021 — @NogDog#1630335

Ooops! I forget about the manual very often because it does my head-in.
Copy linkTweet thisAlerts:
@inktApr 15.2021 — @developer_web#1630370 Because you dont understand what the manual contains, isn't a valid reason to not use it. I have been a web programmer for YEARS, php.net is the first place I go to find information on how php works.
×

Success!

Help @developer_web spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...