What are superglobals in PHP?

Superglobals are built-in variables that PHP creates by itself. They are available in every place of your script (inside functions and classes also), and you do not need the global keyword to use them.

SuperglobalUse
$_GETData sent in the URL
$_POSTData sent by a form using the POST method
$_REQUESTData of GET, POST and cookies together
$_SESSIONSession data of the current user
$_COOKIECookies sent by the browser
$_FILESDetails of uploaded files
$_SERVERServer and request information, like the method and IP address
$_ENVEnvironment variables
$GLOBALSAccess to the global variables
<?php
echo $_SERVER["REQUEST_METHOD"];
?>

Output:

When the page is opened normally in the browser

GET

Note: All the data in $_GET, $_POST and $_COOKIE comes from the visitor, so never trust it. Validate it and escape it before use. See PHP Forms Handling.

Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.