派斯说你可以用卷发。你可以让卷曲只给你的标题,而不是身体,这可能会使它更快。一个糟糕的域总是需要一段时间,因为您将等待请求超时;您可能会使用curl更改超时长度。
下面是一个例子:function remoteFileExists($url) {
$curl = curl_init($url);
//don't fetch the actual page, you only want to check the connection is ok
curl_setopt($curl, CURLOPT_NOBODY, true);
//do request
$result = curl_exec($curl);
$ret = false;
//if request did not fail
if ($result !== false) {
//if request was ok, check response code
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($statusCode == 200) {
$ret = true;
}
}
curl_close($curl);
return $ret;}$exists = remoteFileExists('http://stackoverflow.com/favicon.ico');if ($exists) {
echo 'file exists';} else {
echo 'file does not exist'; }