V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
itommy
V2EX  ›  问与答

请教php高手, 请问怎么catch fopen http request failed 这个error

  •  
  •   itommy · 2011-05-04 00:20:30 +08:00 · 4507 次点击
    这是一个创建于 4740 天前的主题,其中的信息可能已经有所发展或是发生改变。
    现在在用yahoo的api,那url有时好用有时不好用。现在fopen一failed,就全部用到那个相应variable的都error。

    $url2 = "http://yahoo-url-here";

    try {
    $file2 = @fopen($url2, "r");
    } catch(exception $e){
    die('error');
    }
    $i=0;
    while (!feof($file2)) {
    //code here
    $i++
    }

    programming菜鸟,随便写个了try catch在那,没用。
    2 条回复    1970-01-01 08:00:00 +08:00
    summic
        1
    summic  
       2011-05-04 00:52:14 +08:00
    这里已经写明了如何获取异常
    http://developer.yahoo.com/php/howto-reqRestPhp.html
    itommy
        2
    itommy  
    OP
       2011-05-05 10:29:35 +08:00
    @summic document还是要看的阿 我错了 谢谢! :)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4792 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 09:53 · PVG 17:53 · LAX 02:53 · JFK 05:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.