V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
itommy
V2EX  ›  问与答

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

  •  
  •   itommy · May 4, 2011 · 4950 views
    This topic created in 5475 days ago, the information mentioned may be changed or developed.
    现在在用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 replies    1970-01-01 08:00:00 +08:00
    summic
        1
    summic  
       May 4, 2011
    这里已经写明了如何获取异常
    http://developer.yahoo.com/php/howto-reqRestPhp.html
    itommy
        2
    itommy  
    OP
       May 5, 2011
    @summic document还是要看的阿 我错了 谢谢! :)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2724 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:29 · PVG 22:29 · LAX 07:29 · JFK 10:29
    ♥ Do have faith in what you're doing.