php file_get_contents计时读取一个文件/页面 防止读取不到内容
$url = 'http://www.baidu.com/index.php'; $opts = array( 'http' => array( 'method' => 'GET', 'header' => 'Accept-language: en '.'Cookie: foo=bar ', 'timeout'=> 20 ) ); $context = stream_context_create($opts); $t = 0; while($t < 4 && ($getcontent=@file_get_contents($url)) === FAlse ) { $t++; } var_dump($getcontent);