/**
* 功能:判断远程文件是否存在
* 参数: $url -远程文件URL
* 返回:存在返回true,不存在或者其他原因返回false
*/
function remote_file_exists($url)
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
//不下载
curl_setopt($ch, CURLOPT_NOBODY, 1);
//设置超时
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($http_code == 200) {
return true;
}
return false;
} 如果帮助到你,请赏杯奶茶喝~
- 本文链接: https://www.shx1024.top//index/article/details/article_id/94.shtml
- 版权声明:本博客所有文章除特别声明外,均默认采用 许可协议。