<?php
$url = 'http://www.sina.com/index.html';
$headInf = get_headers($url,1);//获取文件头信息
print_r($headInf );//打印文件头信息
echo "/n";
echo $headInf['Last-Modified'];//输出文件最后更新时间
echo "/n";
echo strtotime($headInf['Last-Modified']);//输出最后更新时间UNIX时间戳
?>
运行结果:
Array
(
[0] => HTTP/1.0 200 OK
[Date] => Thu, 24 Apr 2008 12:12:31 GMT
[Server] => Apache/2.0.54 (Unix)
[Last-Modified] => Wed, 23 Apr 2008 16:49:41 GMT
[ETag] => "c3fdc1-1bd6-1e7fb340"
[Accept-Ranges] => bytes
[Content-Length] => 7126
[Content-Type] => text/html
[Age] => 11394
[X-Cache] => HIT from webfront4.sina.com.cn
[Connection] => close
)
Wed, 23 Apr 2008 16:49:41 GMT
1208969381
Content-Length项即文件大小,所以从文件头中可以得到文件大小