我在使用file_get_contents进行获取内容的时候设置了超时时间3秒,但是在获取过程中,发现,有些请求远远超过这个值,代码如下:
$opts = array(
'http' => array(
'method' => "GET",
'timeout' => 3,
)
);
$context = stream_context_create($opts);
$t1 = time();
@$file_data = file_get_contents($url, FALSE, $context);
echo '|耗时:' . (time() - $t1) . '秒|';