title: php to json: reading file returns php code
body: <p>I am trying to set up a php script that returns some db entries to a json file. The script seems to be working when I read it from another website, however, when I try to read the output from the same folder (for testing purposes) it does not work. 
  php code for generating the json:</p>
  
  <pre><code>header('Cache-Control: no-cache, must-revalidate');
  header('Expires: Mon, 01 Jan 1996 00:00:00 GMT');
  header('Content-type: application/json');
  //snipped sql magic
  echo json_encode($rows);
  </code></pre>
  
  <p>When I visit the page on my site it will return what is expected: </p>
  
  <pre><code>[{"id":96,"name":"name1"},{"id":39,"name":"name2"}]
  </code></pre>
  
  <p>So far so good.
  However, when I try to read the output of this file in another php file in the same folder, like </p>
  
  <pre><code>$json = file_get_contents(urlencode('json.php')); //same result without the urlencode
  echo var_dump($jsonData);
  </code></pre>
  
  <p>It will return the <em>php code</em> and not the content of the json file.
  I don't understand why this is. 
  Any thoughts?</p>