【问题标题】:PHP: Merge catchesPHP:合并捕获
【发布时间】:2009-11-21 20:04:13
【问题描述】:

我可以在 PHP 中合并两个 catch 吗?

try {
  // some code
}
catch (App_Exception $e) {
  // do sth.
}
catch (Exception $e) {
  // do the same exception code again
}

【问题讨论】:

    标签: php exception


    【解决方案1】:
    try {
        try {
            // some code
        }
        catch (App_Exception $e) {
            // do sth.
            throw $e;
        }
    }
    catch (Exception $e) {
        // do the same exception code again
    }
    

    【讨论】:

    • 我不明白这会如何改变行为?
    猜你喜欢
    • 2011-09-17
    • 2017-03-01
    • 1970-01-01
    • 2014-04-27
    • 2011-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-11
    相关资源
    最近更新 更多