title: header("HTTP/1.1 400 Bad Request") does not properly redirect when php tag is not at beginning
body: <p>I'm using PHP to check if &quot;itemname&quot; is in GET request; if it isn't, Error 400 page is displayed.</p>
  <pre><code>&lt;?php
      if(isset($_GET[&quot;itemname&quot;])) {          
          // Do something ...
      }
      else {
          header(&quot;HTTP/1.1 400 Bad Request&quot;);
      }
  ?&gt;
  </code></pre>
  <p>I have an issue where if the PHP opening tag (&lt;?php) is not at the beginning of the script, header( ) will not redirect to the error page (I added some CSS styles so &lt;html tag is at the beginning)</p>
  <p>I tested with only php. Apparently, even a space at the beginning will cause header( ) to fail to redirect.</p>
  <pre><code>&lt;?php  &lt;----- Must be at beginning 
      if(isset($_GET[&quot;itemname&quot;])) {          
          // Do something ...
      }
      else {
          header(&quot;HTTP/1.1 400 Bad Request&quot;);
      }
  ?&gt;
  </code></pre>
  <p>What might cause this issue? How can I fix it?</p>