Php 增加繁忙服务器的curl超时
我增加了超时时间,但不起作用Php 增加繁忙服务器的curl超时,php,curl,Php,Curl,我增加了超时时间,但不起作用 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://localhost.com/test.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 999); $response = curl_exec($ch); print_r($res
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost.com/test.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 999);
$response = curl_exec($ch);
print_r($response);
您需要向其添加CURLOPT_CONNECTTIMEOUT选项
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600); //10 minutes
是连接超时吗?或者test.php执行时间太长并且超时了???@Milancheda它甚至没有连接就超时了。@AdamWright那么它是connecttimeout。试试我的答案。