文件获取内容:获取完整响应(PHP)

文件获取内容:获取完整响应(PHP),php,file-get-contents,Php,File Get Contents,我正在使用以下代码将信息发布到URL $query = http_build_query($myvars); $options = array( 'http' => array( 'header' => "Content-Type: application/x-www-form-urlencoded\r\n". "Content-Length: ".strlen($query)."\r\n

我正在使用以下代码将信息发布到URL

$query = http_build_query($myvars);
    $options = array(
        'http' => array(
            'header' => "Content-Type: application/x-www-form-urlencoded\r\n".
                        "Content-Length: ".strlen($query)."\r\n".
                        "User-Agent:MyAgent/1.0\r\n",
            'method'  => "POST",
            'content' => $query,
        ),
    );
    $context = stream_context_create($options);
    $response = file_get_contents($url, false, $context);
是否可以显示响应的完整标题信息

首先我使用curl,但这需要很多cpu。 对于curl,我使用了以下选项:

curl_setopt($ch, CURLOPT_HEADER, 1);
我收到了以下标题信息:

HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Date: Mon, 21 Sep 2015 07:06:35 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.11
Content-Description: File Transfer
Content-Disposition: attachment; filename=File.txt
Content-Transfer-Encoding: binary
Content-Length: 333
Cache-Control: must-revalidate, post-check=0, pre-check=0
Expires: 0
Pragma: public
Vary: Accept-Encoding
Content-Type: text/plain
是否也可以使用包含“获取”内容的文件

  file_get_contents("http://example.com");
  var_dump($http_response_header);

Tx,这就是解决方案Tx,这就是解决方案