title: What is the $_REQUEST precedence?
body: <h1>PHP Superglobal variables</h1>
  
  <p>PHP has global variables which can be accessed within any scope of your script. Three of these variables (<code>$_GET</code>, <code>$_POST</code>, <code>$_COOKIE</code>) are stored within a fourth variable (<code>$_REQUEST</code>). </p>
  
  <h2><a href="http://php.net/manual/en/reserved.variables.get.php" rel="nofollow noreferrer"><code>$_GET</code></a></h2>
  
  <blockquote>
    <p>An associative array of variables passed to the current script via the URL parameters.</p>
  </blockquote>
  
  <p>Consider the following example in which a URL is sent and accessed. </p>
  
  <pre class="lang-none prettyprint-override"><code>http://www.example.com/myPage.php?myVar=myVal
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>echo $_GET["myVar"]; // returns "myVal"
  </code></pre>
  
  <h2><a href="http://php.net/manual/en/reserved.variables.post.php" rel="nofollow noreferrer"><code>$_POST</code></a></h2>
  
  <blockquote>
    <p>An associative array of variables passed to the current script via the HTTP POST method when using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request.</p>
  </blockquote>
  
  <p>An example of this being used is as follows. </p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form action="somePage.php" method="POST"&gt;
      &lt;input type="text" name="myVar" value="myVal" /&gt;
      &lt;input type="submit" name="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>echo $_POST["myVar"]; // returns "myVal"
  </code></pre>
  
  <h2><a href="http://php.net/manual/en/reserved.variables.cookies.php" rel="nofollow noreferrer"><code>$_COOKIE</code></a></h2>
  
  <blockquote>
    <p>An associative array of variables passed to the current script via HTTP Cookies</p>
  </blockquote>
  
  <pre class="lang-php prettyprint-override"><code>setcookie("myVar", "myVal", time() + 3600);
  echo $_COOKIE["myVar"]; // returns "myVal"
  </code></pre>
  
  <h2><a href="http://php.net/manual/en/reserved.variables.request.php" rel="nofollow noreferrer"><code>$_REQUEST</code></a></h2>
  
  <blockquote>
    <p>An associative array that by default contains the contents of <code>$_GET</code>, <code>$_POST</code> and <code>$_COOKIE</code>.</p>
  </blockquote>
  
  <hr>
  
  <h1>Here's the thing</h1>
  
  <p><code>$_REQUEST</code> contains all three in one array and is accessed via <code>$_REQUEST["myVar"]</code>.</p>
  
  <h2>A random scenario</h2>
  
  <p>Let's assume, for whatever reason, that I use the same name for my <code>$_GET</code>, <code>$_POST</code>, and <code>$_COOKIE</code>.</p>
  
  <p>What would the precedence be for what is stored in <code>$_REQUEST</code>.</p>
  
  <p>Assuming I set a sent data through the URL, posted through the form and, set a cookie with the same name as each other (a bizarre scenario, I know).<br>
  Lets say I used the name "example".</p>
  
  <p>What would be the output of the following output?</p>
  
  <pre class="lang-php prettyprint-override"><code>     if ($_REQUEST["example"] == $_GET["example"])    echo "GET";
  else if ($_REQUEST["example"] == $_POST["example"])   echo "POST";
  else if ($_REQUEST["example"] == $_COOKIE["example"]) echo "COOKIE";
  </code></pre>
  
  <h2>tl;dr</h2>
  
  <p>If <code>$_GET</code>, <code>$_POST</code>, and <code>$_COOKIE</code> all have a value stored with the same name; which one will <code>$_REQUEST</code> store under said name?</p>