📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials PHP for Beginners Superglobals

Superglobals

5 min read Quiz at the end
Superglobals are built-in PHP arrays available everywhere in your script without needing global. $_GET and $_POST hold form data, $_SESSION stores user info, and $_SERVER has server details. Always validate data from superglobals before use.

PHP Superglobals

Superglobals are built-in variables available everywhere in PHP.

$_GET["id"]         // URL query string: ?id=5
$_POST["email"]     // Form POST data
$_REQUEST["name"]   // GET + POST + COOKIE
$_SERVER["PHP_SELF"]       // Current script
$_SERVER["REQUEST_METHOD"]  // GET or POST
$_SERVER["HTTP_HOST"]       // Domain
$_SERVER["REMOTE_ADDR"]     // User IP
$_SESSION["user"]   // Session data
$_COOKIE["token"]   // Cookie data
$_FILES["upload"]   // Uploaded file info
$_ENV["DATABASE_URL"] // Environment variables
$GLOBALS["myVar"]   // All global variables
Topic Quiz · 5 questions

Test your understanding before moving on

1. Which superglobal holds POST form data?
💡 $_POST contains data submitted via HTTP POST (form submissions, API calls).
2. Where is the client IP address?
💡 $_SERVER["REMOTE_ADDR"] contains the IP address of the client.
3. Which superglobal holds uploaded file info?
💡 $_FILES contains information about files uploaded via a multipart form.
4. What does $_REQUEST contain?
💡 $_REQUEST merges $_GET, $_POST, and $_COOKIE into one array.
5. Which superglobal stores session data?
💡 $_SESSION stores data that persists across page requests for a user session.