【发布时间】:2014-05-13 17:12:59
【问题描述】:
如果不可能,我不能让 file_get_contents 工作超过 1 秒 - 我需要跳到下一个循环。
for ($i = 0; $i <=59; ++$i) {
$f=file_get_contents('http://example.com');
if(timeout<1 sec) - do something and loop next;
else skip file_get_contents(), do semething else, and loop next;
}
这样的功能可以做吗?
实际上我正在使用 curl_multi,但我不知道如何为整个 curl_multi 请求设置超时。
【问题讨论】:
-
使用流上下文将超时设置为 1 秒。见stackoverflow.com/questions/10236166/…
标签: php loops for-loop timeout limit