我可以捕获exit()和die()消息吗? [英] Can I catch exit() and die() messages?

查看:64
本文介绍了我可以捕获exit()和die()消息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够捕获die()exit()消息.这可能吗?我希望有与set_error_handlerset_exception_handler类似的东西.我已经看过register_shutdown_function(),但是它似乎不包含有问题的die()exit()调用的上下文.

I'd like to be able to catch die() and exit() messages. Is this possible? I'm hoping for something similar to set_error_handler and set_exception_handler. I've looked at register_shutdown_function() but it seems to contain no context for the offending die() and exit() calls.

我意识到die()exit()是处理错误的不好方法.我不希望被告知不要这样做. :)我正在创建一个通用系统,并且希望有人(而不是我)出于某些原因认为这是个好主意,从而能够优雅地记录exit()die().

I realize that die() and exit() are bad ways to handle errors. I am not looking to be told not to do this. :) I am creating a generic system and want to be able to gracefully log exit() and die() if for some reason someone (not me) decides this is a good idea to do.

推荐答案

据我所知,这实际上是不可能的.此处发布的某些解决方案可能会起作用,但它们需要大量其他工作或许多依赖项.无法轻松可靠地捕获die()和exit()消息.

As best as I can tell this is not really possible. Some of the solutions posted here may work but they require a lot of additional work or many dependencies. There is no way to easily and reliable trap the die() and exit() messages.

这篇关于我可以捕获exit()和die()消息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆