title: PHP: "file_get_contents()" returning NULL from content-verified URL
body: <p>I'm betting that it'll end up being something simple ... but I can use a hand in spotting it.</p>
  
  <p><strong>Problem:</strong><br>
  When I try to get the contents of a specific local URL via <code>file_get_contents()</code>, it comes back as an empty string '' (length=0).</p>
  
  <p><strong>What I've tried:</strong></p>
  
  <pre><code>    $url = 'http://localhost/bbq/index.php/company/get/id/2131/return/json';
      $results = file_get_contents($url);
      echo'&lt;pre&gt;Results:&lt;br /&gt;',var_export($results),'&lt;/pre&gt;';
  </code></pre>
  
  <p>When directly visiting <code>http://localhost/bbq/index.php/company/get/id/2131/return/json</code>, everything echos beautifully: <code>{"id":"2131","value":"Acme Anvil Corp."}</code></p>
  
  <p>To check myself, I tried it with <code>$url = 'http://www.google.com'</code>, and it <em>worked as expected</em> so then I tried a separate Local uri, <code>http://localhost/?phpinfo=1</code>, and it <em>also worked</em> just fine.</p>
  
  <p><strong>Question:</strong><br>
  What am I missing???</p>
  
  <p><br></p>
  
  <p><strong>[ADDITIONAL INFO]</strong><br>
  <code>allow_url_fopen</code> is ON</p>
  
  <p>I <em>may</em> have just found <em>something</em>.<br>
  As a safety measure in CODEIGNITER projects, the first line of the controller script has:</p>
  
  <pre><code>    if ( !defined('BASEPATH')) exit('No direct script access allowed');
  </code></pre>
  
  <p>Commenting it out didn't provide any improvements, but I thought it may be worth mentioning nonetheless.</p>
  
  <p>Also, here's a dump of the HTTP Response Header. Maybe someone can see something in there. It all seems pretty straight forward to me, but I don't really know what I should be looking for.</p>
  
  <pre><code>array (size=13)
    0 =&gt; string 'HTTP/1.1 200 OK' (length=15)
    1 =&gt; string 'Date: Thu, 27 Dec 2012 19:58:47 GMT' (length=35)
    2 =&gt; string 'Server: Apache/2.4.2 (Win64) PHP/5.4.3' (length=38)
    3 =&gt; string 'X-Powered-By: PHP/5.4.3' (length=23)
    4 =&gt; string 'Set-Cookie: csrf_cookie_name=4ae46f9a7e612ae22a080a4e88bd349c; expires=Thu, 27-Dec-2012 21:58:47 GMT; path=/' (length=108)
    5 =&gt; string 'Set-Cookie: PHPSESSID=ah70p0ldl5qptcauei1t8ihud3; path=/' (length=56)
    6 =&gt; string 'Expires: Thu, 19 Nov 1981 08:52:00 GMT' (length=38)
    7 =&gt; string 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0' (length=77)
    8 =&gt; string 'Pragma: no-cache' (length=16)
    9 =&gt; string 'Refresh: 0;url=http://localhost/bbq/index.php/index.php/user/login' (length=66)
    10 =&gt; string 'Content-Length: 0' (length=17)
    11 =&gt; string 'Connection: close' (length=17)
    12 =&gt; string 'Content-Type: text/html' (length=23) 
  </code></pre>
  
  <p><strong>[/ADDITIONAL INFO]</strong></p>
  
  <p><strong>BTW,</strong> I'm running:</p>
  
  <ul>
  <li>WAMPSERVER on Win7 64 </li>
  <li>Apache 2.4.2  </li>
  <li>PHP 5.4.3 </li>
  <li>CodeIgniter 2.1.2</li>
  </ul>