您的位置:首页 > 编程语言 > PHP开发

php file_get_contents计时读取一个文件/页面 防止读取不到内容

2013-10-25 13:56 411 查看
php file_get_contents计时读取一个文件/页面 防止读取不到内容

$url = 'http://www.baidu.com/index.php';
$opts = array(
'http' => array(
'method' => 'GET',
'header' => 'Accept-language: en\r\n'.'Cookie: foo=bar\r\n',
'timeout'=> 20
)
);
$context = stream_context_create($opts);
$t     = 0;
while($t < 4 && ($getcontent=@file_get_contents($url)) === FAlse )
{
$t++;
}
var_dump($getcontent);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐