Lesson content
Read, practise, then check your understanding
Superglobals include $_GET, $_POST, $_COOKIE, $_FILES, $_SERVER, $_ENV, $_SESSION, $_REQUEST, and $GLOBALS. Availability does not imply trust.
Practical example
<?php
$page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, ['options' => ['default' => 1, 'min_range' => 1]]);
$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
Copy validated values into named domain inputs rather than passing superglobals through the application. Avoid $_REQUEST because it hides provenance. Proxy headers, filenames, environment values, and cookies require explicit trust/configuration rules.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.