get_headers:发送服务器响应HTTP请求
get_headers(字符串url[链接格式])
get_headers()以数组的形式返回服务器HTTP请求。如果执行失败,将返回FALSE和一个错误的水平E_WARNING》。
可选参数设置为1,get_headers()能分析系统的响应速度和集数组中的键。
注意:使用该函数需要把 php.ini里面的allow_url_fopen = On,才能使用。
实例如下:
$url = http://www.ite5e.com;
print_r(get_headers($url));
print_r(get_headers($url, 1));
?>
打印结果:
Array
(<br> [0] => HTTP/1.1 200 OK<br> [1] => Connection: close<br> [2] => Date: Tue, 16 Nov 2010 09:48:20 GMT<br> [3] => Content-Length: 52708<br> [4] => Content-Type: text/html<br> [5] => Content-Location: http://www.ite5e.com/index.html<br> [6] => Last-Modified: Tue, 16 Nov 2010 09:19:13 GMT<br> [7] => Accept-Ranges: bytes<br> [8] => ETag: "50d16c556f85cb1:b1f76"<br> [9] => Server: Microsoft-IIS/6.0<br> [10] => X-Powered-By: ASP.NET<br>)<br>Array<br>(<br> [0] => HTTP/1.1 200 OK<br> [Connection] => close<br> [Date] => Tue, 16 Nov 2010 09:48:21 GMT<br> [Content-Length] => 52708<br> [Content-Type] => text/html<br> [Content-Location] => http://www.ite5e.com/index.html<br> [Last-Modified] => Tue, 16 Nov 2010 09:19:13 GMT<br> [Accept-Ranges] => bytes<br> [ETag] => "50d16c556f85cb1:b1f76"<br> [Server] => Microsoft-IIS/6.0<br> [X-Powered-By] => ASP.NET<br>)