file get contents - file_get_contents: get full response (PHP) -
i'm using following code post information 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); is possible show complete header information of response.
first used curl, took cpu. curl used following option:
curl_setopt($ch, curlopt_header, 1); and received following header information:
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 is file_get_contents possible?
  file_get_contents("http://example.com");   var_dump($http_response_header); http://php.net/manual/en/reserved.variables.httpresponseheader.php
Comments
Post a Comment