使用cURL的最长执行时间

时间:2015-10-16 23:50:52

标签: php curl

我收到了错误         致命错误:超过30秒的最长执行时间

这很奇怪,因为我将超时设置为0。

    function curl(){

        $this->options = Array(
        CURLOPT_RETURNTRANSFER => TRUE,   
        CURLOPT_FOLLOWLOCATION => FALSE, 
        CURLOPT_CONNECTTIMEOUT => 0, 
        CURLOPT_TIMEOUT => 0, 
        CURLOPT_MAXREDIRS => 20, 
        CURLOPT_USERAGENT => random_user_agent(), 
        CURLOPT_URL => $this->url, 
      );

       $this->ch = curl_init(); //Initalising curl;
     curl_setopt_array($this->ch, $this->options); 
     $this->data = curl_exec($this->ch); // Executing cURL;
     curl_close($this->ch);


     return $this->data;
     }  

有谁知道问题可能是什么?

非常感谢任何回复。

1 个答案:

答案 0 :(得分:5)

指定0基本上是{cnrl请求的eliminates the timeout

但是,PHP脚本本身的运行时间不能超过30 seconds (by default。因此,如果请求超过30秒,PHP脚本本身将被终止,从而产生您获得的消息,无论它是cUrl还是只是导致脚本花费那么长时间的另一段代码。

相关问题