开发者

How to remove CURL time limit in PHP?

I am running a rather long script that fetches the contents of a specified domain and parses the html before running a series of tests on said html. Anyw开发者_Go百科ay the script times out after a while. I tried putting this at the top of my page but still no luck:

set_time_limit(0);

Here is the error in question:

cURL error number:28
cURL error:Operation timed out after 10000 milliseconds with 316183 out of 6476018 bytes received


You need to set the amount of time curl gets to complete its operations with curl_setopt.

The CURLOPT_TIMEOUT setting to be specific.

curl_setopt($ch, CURLOPT_TIMEOUT, 400); // the timeout in seconds

http://www.php.net/manual/en/function.curl-setopt.php


Use the CURLOPT_TIMEOUT option in conjunction with curl_setopt().

curl_setopt($curl, CURLOPT_TIMEOUT, 0); // zero waits indefinitely

set_time_limit() only sets how long the script can run. The issue you're having is a cURL timout.

http://php.net/curl-setopt


Set CURLOPT_TIMEOUT to a higher value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜