在有限的时间内执行php file_get_content并退出

时间:2016-04-03 04:54:47

标签: php timeout

是否可以运行php file_get_content最多25秒并停止收到的内容并继续?目标是捕获超时错误。

这不会解决问题,因为它只会延长时间和最终的致命错误。

$opts = array('http' => array('method'  => 'GET', 'timeout' => 120));
$context  = stream_context_create($opts);
$html = @file_get_contents($crLink, false, $context);

0 个答案:

没有答案