Feb
21
2024
php判断远程文件是否存在的办法
作者:
绝缘体.. 发布:
2024-02-21 09:21 分类:
未分类 阅读:
抢沙发
php如何判断一个远程文件是否存在呢?下面是作者在网上找到的方法,在这里和大家分享一下。
更准确的判断方法请参考:
使用 php 检查一个通过 http 协议访问的网络文件是否存在
//php判断远程文件是否存在
function url_exists($url){
$handle=curl_init($url);
if(false===$handle){
return false;
}
curl_setopt($handle,CURLOPT_HEADER,false);
curl_setopt($handle,CURLOPT_FAILONERROR,true);
curl_setopt($handle,CURLOPT_NOBODY,true);
curl_setopt($handle,CURLOPT_RETURNTRANSFER,false);
$connectable=curl_exec($handle);
//http://www.phpernote.com/php-function/744.html
curl_close($handle);
return $connectable;
}
微信扫一扫,打赏作者吧~