PHP Supergroup Variables
PHP has global variables that can be accessed in any area of your script. Three of these variables ( $_GET , $_POST , $_COOKIE ) are stored in the fourth variable ( $_REQUEST ).
An associative array of variables passed to the current script via URL parameters.
Consider the following example in which a URL is sent and accessed.
http://www.example.com/myPage.php?myVar=myVal
echo $_GET["myVar"];
An associative array of variables passed to the current script through the HTTP POST method when using the / x -www-form-urlencoded or multipart / form-data applications as the HTTP Content-Type in the request.
An example of this is the following.
<form action="somePage.php" method="POST"> <input type="text" name="myVar" value="myVal" /> <input type="submit" name="submit" value="Submit" /> </form>
echo $_POST["myVar"];
An associative array of variables passed to the current script via HTTP cookies
setcookie("myVar", "myVal", time() + 3600); echo $_COOKIE["myVar"];
An associative array that by default contains the contents of $_GET , $_POST and $_COOKIE .
Here thing
$_REQUEST contains all three in one array and is accessible through $_REQUEST["myVar"] .
Random script
Suppose, for some reason, that I use the same name for my $_GET , $_POST and $_COOKIE .
What will be the priority for what is stored in $_REQUEST .
Assuming I set the submitted data via the URL sent through the form and setting cookies with the same name as the others (weird scenario, I know).
Suppose I used the name "example".
What will be the output of the next output?
if ($_REQUEST["example"] == $_GET["example"]) echo "GET"; else if ($_REQUEST["example"] == $_POST["example"]) echo "POST"; else if ($_REQUEST["example"] == $_COOKIE["example"]) echo "COOKIE";
TL; DR
If $_GET , $_POST and $_COOKIE all have a value stored with the same name; which will $_REQUEST store under the specified name?