本文主要和大家分享php是否远程文件判断方法,希望能帮助到大家。
function chk_remote_file_exists($url) {
$ch = curl_init();
$timeout = 10;
curl_setopt ($ch, curlopt_url, $url);
curl_setopt ($ch, curlopt_header, 1);
curl_setopt ($ch, curlopt_returntransfer, 1);
curl_setopt ($ch, curlopt_connecttimeout, $timeout);
$contents = curl_exec($ch);
if (preg_match("/404/", $contents)) {
return false;
}
return true;
}
$url = 'http://www.lvxing1788.com/lvxing.html';
var_dump(chk_remote_file_exists($url));
exit;
相关推荐:
php实现下载远程文件类相关代码
php如何判断本地与远程文件是否存在的实例分析
php下载远程文件类分享
以上就是php是否远程文件判断方法的详细内容。