Superglobals as Concepts
Server Values
$_SERVER holds request and runtime context such as the request method.
Server Values
server_values.php
<?php
$method = ;
$_SERVER["REQUEST_METHOD"] = $method;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$isPost = $_SERVER["REQUEST_METHOD"] === "POST";
$context = $method === "CLI" ? "command" : ($isPost ? "form" : "page");
echo "method=" . $_SERVER["REQUEST_METHOD"] . "\n";
echo "script=" . $_SERVER["SCRIPT_NAME"] . "\n";
echo "context=" . $context . "\n";
<?php
$method = ;
$_SERVER["REQUEST_METHOD"] = $method;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$isPost = $_SERVER["REQUEST_METHOD"] === "POST";
$context = $method === "CLI" ? "command" : ($isPost ? "form" : "page");
echo "method=" . $_SERVER["REQUEST_METHOD"] . "\n";
echo "script=" . $_SERVER["SCRIPT_NAME"] . "\n";
echo "context=" . $context . "\n";
<?php
$method = ;
$_SERVER["REQUEST_METHOD"] = $method;
$_SERVER["SCRIPT_NAME"] = "/index.php";
$isPost = $_SERVER["REQUEST_METHOD"] === "POST";
$context = $method === "CLI" ? "command" : ($isPost ? "form" : "page");
echo "method=" . $_SERVER["REQUEST_METHOD"] . "\n";
echo "script=" . $_SERVER["SCRIPT_NAME"] . "\n";
echo "context=" . $context . "\n";
request context
Server values describe how a script is being reached, not just what data was submitted.