file_get_contents有时能读出,有时读不出

十分不稳定,怎么解决?急死了,谁能回答十分感谢

[b]问题补充:[/b]
好的,十分感谢。

可是它把错误信息也获取到了:
Warning: file_get_contents(http://bbs.phpchina.com/rss.php?fid=17&auth=Lg37Y6QgN4fqGp%2F7E2hHFGk%2BoZG2VLcc5g) [function.file-get-contents]: failed to open stream: HTTP request failed! in E:\AppServ\www\demoWeb\xmlRead2.php on line 65

Warning: file_get_contents(http://bbs.phpchina.com/rss.php?fid=17&auth=Lg37Y6QgN4fqGp%2F7E2hHFGk%2BoZG2VLcc5g) [function.file-get-contents]: failed to open stream: HTTP request failed! in E:\AppServ\www\demoWeb\xmlRead2.php on line 65
Array ( [0] => AminoAcid Object ( [title] => 鏌ヨ鍔熻兘,浠d,鍚嶇О,鏃堕棿鏌ヨ鏃跺垽鏂棶棰� [link] => http://bbs.phpchina.com/viewthread.php?tid=128263 [description] => [category] => 闂瓟姹傚姪鍖� [author] => winver [pubDate] => Mon, 15 Jun 2009 08:00:19 +0000 ) [1] => AminoAcid Object ( [title] => smarty涓繍鐢╦s鐨勯棶棰� [link] => http://bbs.phpchina.com/viewthread.php?tid=128262 [description] => [category] => 闂瓟姹傚姪鍖� [author] => dayi4ban [pubDate] => Mon, 15 Jun 2009 07:53:31 +0000 ) [2] => AminoAcid Object ( [title] => jQuery Radio 鐨勫彇鍊�,Safari 涓柟娉曪紵 [link] => http://bbs.phpchina.com/viewthread.php?tid=128258 [description] => [category] => 闂瓟姹傚姪鍖� [author] => Rainstorm [pubDate] => Mon, 15 Jun

如何只得到xml内容,而得不到得错误信息输出则滤过呢??
得到的是string还是array,如何传值给js再处理呢??

php

3个回答

加入判断次数。假设只检查4次。

$i=0;
while(!$content or $i==4){
  @$content =file_get_contents($url);
  $i++;
}
if($i==4) exit("next");

@的作用:过滤错误提示

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!