title: php header printing full html code on browser
body: <p>I am making a simple API from PHP.</p>
  <p>Code Snippet:</p>
  <pre><code>        elseif ($_GET[&quot;command&quot;]=&quot;verifyconn&quot;){
              header(&quot;Content-Type: application/json&quot;);
              $data=array(&quot;response&quot; =&gt; &quot;success&quot;);
              echo json_encode($data);
              exit;
          }
  </code></pre>
  <p>Whenever this is executed, I get this response on browser:</p>
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset=&quot;utf-8&quot;&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;{&quot;response&quot;:&quot;wrong_secret&quot;}
  </code></pre>
  <p>The whole HTML code gets printed on browser. When I remove <code>header(&quot;Content-Type: application/json&quot;);</code>, it gets fixed and JSON displays but in text. How can I fix it?</p>