你可能想尝试做类似这样的
<?php
function url_exists($url) {
// Version 4.x supported
$handle = curl_init($url);
if (false === $handle)
{
return false;
}
curl_setopt($handle, CURLOPT_HEADER, false);
curl_setopt($handle, CURLOPT_FAILONERROR, true); // this works
curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15")); // request as if Firefox
curl_setopt($handle, CURLOPT_NOBODY, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, false);
$connectable = curl_exec($handle);
curl_close($handle);
return $connectable;
}
?>
来源的东西:http://uk.php.net/manual/en/function.file-exists.php#85246
的原因是是,作为已经提到检查对FOPEN的原始值是不是最好的主意和此外,该方法不考虑被重定向到错误页面等。
仍然将每个图像设置为不存在的图像。为什么会这样做? – 2009-02-06 14:52:29