PHP中的异常 - 未被捕获 [英] Exceptions in PHP - uncaught
本文介绍了PHP中的异常 - 未被捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用来写我自己的例外在php,它很容易ectually。你所做的就是这样:
I use to writing my own exceptions in php, its pretty easy ectually. all you have do is something like:
class Test extends Exception{
public function __construct($message, $code = 0){
}
}
我不断得到的问题是我曾经做过类似的事情:
the problem I keep getting is that when ever I do something like:
throw new Test('bla');
我得到:
uncaught exception with message bla.
为什么?
推荐答案
因为你没有抓住它,也许? :p
Because you didn't catch it, maybe? :p
try {
throw new Test('bla');
}
catch (Exception $e)
{
// caught it
}
请查看手册正确的异常使用
这篇关于PHP中的异常 - 未被捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文