title: HTTP requests with file_get_contents, getting the response code
body: <p>I'm trying to use <code>file_get_contents</code> together with <code>stream_context_create</code> to make POST requests. My code so far:</p>
  
  <pre><code>    $options = array('http' =&gt; array(
          'method'  =&gt; 'POST',
          'content' =&gt; $data,
          'header'  =&gt; 
              "Content-Type: text/plain\r\n" .
              "Content-Length: " . strlen($data) . "\r\n"
      ));
      $context  = stream_context_create($options);
      $response = file_get_contents($url, false, $context);
  </code></pre>
  
  <p>It works fine, however, when an HTTP error occurs, it spits out a warning:</p>
  
  <pre><code>file_get_contents(...): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
  </code></pre>
  
  <p>and returns false. Is there a way to:</p>
  
  <ul>
  <li>suppress a warning (I'm planning to throw my own exception in case of failure)</li>
  <li>obtain the error information (at least, the response code) from the stream</li>
  </ul>