Chinaunix
标题:
nginx editer
[打印本页]
作者:
yangbosos
时间:
2009-11-09 18:18
标题:
nginx editer
http://hi.baidu.com/beibeiboo/blog/item/cb975473dfbb7f148701b097.html
用 file_get_contents 访问 http 时取回响应头
php 的 file_get_contents 可以直接用 url 读取网页,用来抓内容很方便。而且用 context 参数指定请求头。
不过在 file_get_contents 的手册页里没说怎么取得响应头。实际上,php 文件函数能访问 http 都是用的 stream wrapper 的东西,把不同形式的流包装成文件。在用 file_get_contents 访问 http 时,stream wrapper 会把响应头放到当前作用域下的 $http_response_header 数组变量里。
e.g.
file_get_contents('http://www.blogbus.com/');
var_dump($http_response_header);
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u/12909/showart_2090145.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2