function url_exists($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_NOBODY, 1); // 不下载
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
return (curl_exec($ch)!==false) ? true : false;
}
用这个函数判断网址是否存在,传入的url如果是字母能很快判断是否存在,传入的url是中文,判断会变得很慢,为什么?请问有什么改进方法?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
学习是最好的投资!