note 98419 deleted from reserved.variables.get by salathe

From: Date: Mon, 21 Sep 2020 14:47:58 +0000
Subject: note 98419 deleted from reserved.variables.get by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215315@lists.php.net to get a copy of this message
Note Submitter: John Galt ---- Just a note, because I didn't know for sure until I tested it. If you have a query string that contains a parameter but no value (not even an equals sign), like so: http://path/to/script.php?a The following script is a good test to determine how a is valued: <pre> <?php print_r($_GET); if($_GET["a"] === "") echo "a is an empty string\n"; if($_GET["a"] === false) echo "a is false\n"; if($_GET["a"] === null) echo "a is null\n"; if(isset($_GET["a"])) echo "a is set\n"; if(!empty($_GET["a"])) echo "a is not empty"; ?> </pre> I tested this with script.php?a, and it returned: a is an empty string a is set So note that a parameter with no value associated with, even without an equals sign, is considered to be an empty string (""), isset() returns true for it, and it is considered empty, but not false or null. Seems obvious after the first test, but I just had to make sure. Of course, if I do not include it in my browser query, the script returns Array ( ) a is null

« previous php.notes (#215315) next »