php - PHP 中的异常处理 : where does $e goes?

标签 php exception

我一直在搜索这个,但我似乎在这段代码中遇到了相同的文章:

   try
    {
        //some code

    }
    catch(Exception $e){
        throw $e;
    }

$e 存储在哪里或网站管理员如何查看它?我应该寻找一个特殊的功能吗?

最佳答案

Exception object (在这种情况下,$e)从 catch{} block 内抛出将被下一个最高的 try{} catch{} block 捕获。

这是一个愚蠢的例子:

try {
    try {
        throw new Exception("This is thrown from the inner exception handler.");
    }catch(Exception $e) {
        throw $e;
    }
}catch(Exception $e) {
    die("I'm the outer exception handler (" . $e->getMessage() . ")<br />");
}

上面的输出是

I'm the outer exception handler (This is thrown from the inner exception handler.)

关于php - PHP 中的异常处理 : where does $e goes?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/957223/

相关文章:

php - codeigniter:如何从指定索引转换数组值?

php - 使用 PHP 编写一个字谜函数?

java - 如何捕获继承类型的异常

oracle - ORA-08177: 无法序列化此事务的访问

PHP 从不同 div 容器中的两个表单发送(由 ajax 生成)

php - 如何从PHP代码中的局部变量选择mysql表中的行名称?

exception - 如何记录部署在 tomcat 中的特定包的异常

exception - 值多态和 "generating an exception"

php - 即使将 html 和 php 设置为 UTF-8,£ 仍然出现在电子邮件中

delphi - 测试强制转换 OleVariant 是否会引发异常(不引发异常)