Reading GET data
suggest changeData from a GET request is stored in the superglobal $_GET in the form of an associative array.
Accessing a missing key is Warning: Undefined array key since PHP 8.0, and was a Notice before that. isset() and ?? do not warn. empty() does not warn either, but it treats "0" as empty.
Example: (for URL /topics.php?author=alice&topic=php)
$author = isset($_GET["author"]) ? $_GET["author"] : "NO AUTHOR";
$topic = isset($_GET["topic"]) ? $_GET["topic"] : "NO TOPIC";
echo "Showing posts from $author about $topic";
$author = $_GET["author"] ?? "NO AUTHOR";
$topic = $_GET["topic"] ?? "NO TOPIC";
echo "Showing posts from $author about $topic";
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents