[英]CURLOPT_TIMEOUT not working in php / windows?
我在XAMPP和Windows上使用以下功能。 但是我一直收到“致命错误:超过30秒的最大执行时间”
有小费吗?
function is_404($url) {
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($handle, CURLOPT_TIMEOUT,10);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT,10);
/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);
/* Check for 404 (file not found). */
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
/* If the document has loaded successfully without any redirection or error */
if ($httpCode >= 200 && $httpCode < 300) {
return false;
} else {
return true;
}
}
您的libcurl版本中可能存在错误。 也许您可以尝试升级到最新版本?
您可以在该系统上(特定的URL上)运行curl命令行工具来调试发生的情况吗? 如果可以的话,使用-v或--trace-ascii选项应该很有价值,以准确显示curl的作用和不作用。
您的代码应该按编写的方式工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.