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 關注
- 174 瀏覽
添加回答
舉報