php的file_get_contents函数访问URL显示响应头

作者:matrix 发布时间:2014 年 10 月 1 日 分类:零零星星

在用 file_get_contents 访问 http 时,stream wrapper 会把响应头放到当前作用域下的 $http_response_header 数组变量里。

所以说变量$http_response_header就保存了需要的响应头,输出这个变量也就能拿到响应头。

file_get_contents('http://www.hhtjim.com/');
print_r($http_response_header);//输出响应头内容

参考:
http://www.jbxue.com/article/16319.html

PS: 阅读剩余部分 »