脚本宝典收集整理的这篇文章主要介绍了PHP最后修改远程文件的时间,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$curl = curl_init(); curl_setopt($curl,CURLOPT_URL,$url); //don't fetch the actual page,you only want headers curl_setopt($curl,CURLOPT_NOBODY,true); curl_setopt($curl,CURLOPT_HEADER,true); //stop IT From outputting stuff to stdout curl_setopt($curl,CURLOPT_RETURNtransfer,true); // attempt to retrieve the modification date curl_setopt($curl,CURLOPT_FILETIME,true); $result = curl_exec($curl); echo $result; $info = curl_getinfo($curl); PRint_r($info); if ($info['filetime'] != -1) { //otherwise unkNown echo date("Y-m-d H:i:s",$info['filetime']); //etc }
这段代码的问题我一直在获得filetime = -1.但是当我删除
curl_setopt($curl,true);
然后我得到正确的修改时间.
curl_setopt($curl,true);
提前致谢
当我调试PHP cURL的东西时,我经常发现使用* nix框(我的mac或ssh到服务器)并从命令行运行请求很有用,所以我可以看到结果而不用担心是否PHP正在做正确的事情,直到我让cURL部分工作.例如:
$curl --head stackoverflow.COM HTTP/1.1 200 OK Cache-Control: public,max-age=49 Content-Length: 190214 Content-tyPE: text/htML; charset=utf-8 Expires: Mon,10 Oct 2011 07:22:07 GMT Last-Modified: Mon,10 Oct 2011 07:21:07 GMT VARy: * Date: Mon,10 Oct 2011 07:21:17 GMT
以上是脚本宝典为你收集整理的PHP最后修改远程文件的时间全部内容,希望文章能够帮你解决PHP最后修改远程文件的时间所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。