/*设置超时配合失败之后尝试多次读取,效果比原先好很多*/
$url = 'http://www.itokit.com';
$opts = array(
'http'=>array(
'method'=>"GET",
'timeout'=>1, //设置超时
)
);
$context = stream_context_create($opts);
$contents = @file_get_contents($url,false,$context);
?>
/*设置超时配合失败之后尝试多次读取,效果比原先好很多*/
$url = 'http://www.itokit.com';
$opts = array(
'http'=>array(
'method'=>"GET",
'timeout'=>1, //设置超时
)
);
$context = stream_context_create($opts);
$contents = @file_get_contents($url,false,$context);
?>
转载于:https://my.oschina.net/shunshun/blog/191833