PHP获取远程文件最后更新时间

<?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项即文件大小,所以从文件头中可以得到文件大小

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值