PHP判断远程文件是否存在
PHP判断远程文件是否存在function FileExists($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)){
echo '文件不存在';
}
}
页:
[1]