title: PHP: Empty result - file_get_contents
body: <p>i am using file_get_contents to run a php script on my website that will export some data in a textfile. The php script "export.php" prints out "OK" when the job is done and "Error" if an error occures.</p>
  
  <p>If i run export.php in my browser it will print "OK" if i run it by calling file_get_contents in another php script the result is empty. But export.php prints in any case "OK" or "Error". </p>
  
  <p>This is my script that calls export.php:</p>
  
  <pre><code>$opts = array('http' =&gt;
                  array(
                      'method'  =&gt; 'GET',
                      'timeout' =&gt; 240 
                  )
              );
  
              $context  = stream_context_create($opts);
              $url_pre = "http://";
              $url = "127.0.0.1/export.php";
              $html = @file_get_contents($url_pre.$url,false,$context);
              if ($html === false){
                  $job_ok=false;
                  $result=error_get_last();
                  echo "Error: ".$result."&lt;br /&gt;";
              }else{
                  if (substr($html,0,2)=="OK"){
                      $job_ok=true;
                      $errurl = "";
                      $result="Job done";
                      echo "Job done: ".$result."&lt;br /&gt;";
                  }else{
                      $job_ok=false;
                      $errurl = $url_pre.$url;
                      $result=$html;
                      echo "Error: ".$result."&lt;br /&gt;";
                  }
              }
              echo "HTML: $html &lt;br /&gt;";
  </code></pre>
  
  <p>The result of the script is:</p>
  
  <blockquote>
    <p>Error:</p>
  </blockquote>
  
  <p>If i open "<a href="http://127.0.0.1/export.php" rel="nofollow">http://127.0.0.1/export.php</a>" in my browser i get:</p>
  
  <blockquote>
    <p>OK</p>
  </blockquote>
  
  <p>Maybe someone can help me!</p>
  
  <p>Thanks!</p>