2 回答

TA贡献1810条经验 获得超4个赞
也许是这样的?
<?php
class MyException extends Exception {
public function __construct() {
parent::__construct('my exception');
}
}
class MyClass {
public function __construct()
{
// myExceptionHandler handles this exception
//throw new Exception("Exception from " . __METHOD__);
}
public function doStuff()
{
// myExceptionHandler handles this exception
//throw new Exception("Exception from " . __METHOD__);
}
public function __destruct()
{
// default exception handler
throw new MyException();
}
}
$myclass = new MyClass();
$myclass->doStuff();
- 2 回答
- 0 关注
- 187 浏览
添加回答
举报