CURLOPT_TIMEOUT 在 php/windows 中不起作用? [英] CURLOPT_TIMEOUT not working in php / windows?
问题描述
我在 XAMPP 和 Windows 中使用以下函数.但我不断收到致命错误:超过 30 秒的最大执行时间"
I am using the following function with XAMPP and Windows. But I keep getting "Fatal error: Maximum execution time of 30 seconds exceeded "
有什么建议吗?
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 版本可能存在错误.也许您可以尝试升级到更新的版本?
There might be a bug in your version of libcurl. Perhaps you can try to upgrade to a more recent version?
您能否在该系统上(在特定 URL 上)运行 curl 命令行工具来调试发生的情况?如果可以,使用 -v 或 --trace-ascii 选项应该有助于准确显示 curl 的作用和不作用.
Can you run the curl command line tool on that system (on the particular URL) to debug what happens? If you can, using the -v or --trace-ascii options should be valuable to show exactly what curl does and doesn't.
您的代码应该像编写的那样工作.
Your code is supposed to work just as written.
这篇关于CURLOPT_TIMEOUT 在 php/windows 中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!