title: Should I Use PHP Superglobals or Filter Input to Retrieve $_GET data?
body: <p>I really hate global variables - maybe its the C# programmer in me but when I'm working in PHP I grit my teeth every time I have to do something like this:</p>
  
  <pre><code>$strUsername = $_GET['username'];
  </code></pre>
  
  <p>Yes, I'm grossly oversimplifying it and yes yes I sanitize all of this properly. In fact, for the framework that I built, all of the superglobals are grabbed almost at the beginning of execution and are dependency-injected from there on out.</p>
  
  <p>I ran across this function in the PHP manual (you truly learn something new every day): filter_input_array().</p>
  
  <p>So now, technically, I can do this instead of grabbing everything from the GET superglobal:</p>
  
  <pre><code>$GETdata = filter_input_array(INPUT_GET);
  </code></pre>
  
  <p>.... and so on and so forth with the others like POST, REQUEST, etc. My question is: should I use filter_input_array and so avoid the scourge of superglobals, or is there some reason to stick with them and forget about using the filter_input functions? What is everyone else's experience with this?</p>
  
  <p>EDIT: I forgot one thing - the filter_input functions are blind to any script-level modifications you make to the superglobals so if I do: <code>$_GET['cheese'] = 'puff';</code> trying to do <code>filter_input(INPUT_GET, 'cheese');</code> later will return null. This is fine since I dependency inject everything but it could catch somebody off guard later, if they are unaware.</p>