作者KawasumiMai (モウソウ×ボウソウ)
看板PHP
标题[请益] file_get_contents 错误排除
时间Thu Aug 16 14:27:04 2012
file_get_contents函数
如果发生任何错误,要怎麽产生动作而不印出warning?
目前是发生failed to open stream: HTTP request failed!
然後会印出错误讯息
好像没有跟fopen一样,有or die("错误讯息")的样子
$response=file_get_contents($url);
if(!$response)
这点也失败了
希望能够排除这种可能会爆版的情况
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.62.200.105
1F:推 waterme1on:$response = @file_get_contents($url); 这样吗? 08/16 14:39
2F:→ KawasumiMai:一语惊醒梦中人...太强了... 08/16 15:03
3F:→ cleanwind:XD 08/16 16:23
4F:→ gname:别掩耳盗铃啊~ 08/17 13:51
5F:→ chrisQQ:用了 @ 之後最好在包 try catch 自己丢出 exception 08/17 16:32
6F:→ chrisQQ:看要记在哪都好 XD 不然以後超难 debug 的 08/17 16:32