您好,欢迎访问一九零五行业门户网

异常处理try-catch-finally_PHP教程

php5.5新增 finally模块
try {
    //好好干,出了问题不要怕,外面有人接应
} catch (httpexception $e) {
    //时刻准备着,处理上面抛出的http问题
} catch (exception $e) {
    //时刻准备着,处理他们都处理不了的问题
} finally {
    //打扫战场,都收拾好了再走人
}
try 中 return 后 finally 会继续执行,如果 finally 中也有return,则最终返回值为 finally 中 return 的值。
try 中 die 或 exit 后 finally 不会执行。
example01:
getmessage();}/* the output from above will look like this: an error occurred exception erased without the return statement in the finally block it would look like this: an error occurred result: error*/
example02:
getprevious()->getmessage() .
; } echo the exception is: . $e->getmessage() .
;}
example04
getmessage()); } } }//报错://fatal error: class 'somenamespace\exception' not found in c:\xampp\htdocs\tonglei\index.php on line 8
example05

http://www.bkjia.com/phpjc/769758.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/769758.htmltecharticlephp5.5新增 finally模块 try { //好好干,出了问题不要怕,外面有人接应 } catch (httpexception $e) { //时刻准备着,处理上面抛出的http问题 } catch (...
其它类似信息

推荐信息