在php中获取Headers响应


Get Headers response in php

我查看了在标签页头有部分的Inspect Element:

In Form Data section:
isslverify:true
iagent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0
ihttpheader:true
url:https://docs.google.com/file/d/0B2_6BBaiKDFLYlBVR1QwUko0UHc/edit?pli=1

如何在PHP代码中获取这些信息。

谢谢!

print_r(get_headers($url));

这将打印所有与标题相关的数据

http://php.net/manual/en/function.get-headers.php

你必须使用get_headers PHP函数:

// set the url you want to get the headers
$url = 'http://www.example.com';
// print out the headers on a non-associative array
var_dump(get_headers($url));
// build it up an associative array
var_dump(get_headers($url, 1));