Originally published on zero2php.dev — part of the Zero to PHP course. View this lesson on the original site.
GET and POST
$_GET — query string parameters (?name=ada).
$_POST — typical body fields for HTTP POST (often forms).
REQUEST
$_REQUEST — convenience merge (configuration-dependent)—prefer $_GET / $_POST explicitly when you can.
SERVER
$_SERVER — request metadata (host, URI, method). Handy for debugging:
<?php
declare(strict_types=1);
echo $_SERVER['REQUEST_METHOD'] ?? 'CLI', "\n";
In CLI exercises, some keys may be absent—this is normal.
Exercise
echo $_SERVER['REQUEST_METHOD'] ?? 'CLI'—in the CLI grader this should print CLI.
From Zero to PHP — Control flow, functions, arrays, and the web