How do I catch a PHP fatal (`E_ERROR`) error?

前端 未结 17 2263
北荒
北荒 2020-11-21 06:21

I can use set_error_handler() to catch most PHP errors, but it doesn\'t work for fatal (E_ERROR) errors, such as calling a function that doesn\'t e

17条回答
  •  [愿得一人]
    2020-11-21 06:48

    You cannot throw an exception inside a registered shutdown function like that:

    method()
        } catch(Exception $e) {
            # This won't work
        }
    ?>
    

    But you can capture and redirect request to another page.

    method()
    ?>
    

提交回复
热议问题