title: File_get_contents($url): failed to open stream
body: <p>I have a script where I read a file using:</p>
  
  <pre><code>file_get_contents(urlencode($url));
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>failed to open stream: HTTP request failed! HTTP/1.0 400 Bad request
  </code></pre>
  
  <p>I tried <a href="http://php.net/manual/fr/function.file-get-contents.php" rel="nofollow">this</a>, but I still get the error.
  I've tried this:</p>
  
  <pre><code>ini_set('default_socket_timeout', 120);
  </code></pre>
  
  <p>This:</p>
  
  <pre><code>$opts = array('http'=&gt;array('timeout' =&gt; 120));
           $context = stream_context_create($opts);
           $resul = file_get_contents($url,0,$context);
  </code></pre>
  
  <p>And this:</p>
  
  <pre><code>$opts = array('http'=&gt;array('timeout' =&gt; 120,'header'=&gt;'Connection : close'));
           $context = stream_context_create($opts);
           $resul = file_get_contents($url,false,$context);
  </code></pre>
  
  <p>Can you help me figure out why I get the error?</p>