php:捕获异常并继续执行,这可能吗? [英] php: catch exception and continue execution, is it possible?
本文介绍了php:捕获异常并继续执行,这可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以捕获异常并继续执行脚本?
Is it possible to catch exception and continue execution of script?
推荐答案
当然,只需在要继续执行的地方捕获异常即可.
Sure, just catch the exception where you want to continue execution...
try
{
SomeOperation();
}
catch (SomeException $e)
{
// do nothing... php will ignore and continue
}
当然,这有一个问题,即静默删除可能是非常重要的错误. SomeOperation()可能会导致其他难以解决的细微问题,但您永远不会知道是否静默删除该异常.
Of course this has the problem of silently dropping what could be a very important error. SomeOperation() may fail causing other subtle, difficult to figure out problems, but you would never know if you silently drop the exception.
这篇关于php:捕获异常并继续执行,这可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文