
异常是程序执行过程中出现的问题。在程序执行过程中,发生异常时,该语句后面的代码将不会被执行,PHP 将尝试查找第一个匹配的 catch 块。如果未捕获异常,则会发出 PHP 致命错误,并显示“未捕获异常”。
基于Intranet/Internet 的Web下的办公自动化系统,采用了当今最先进的PHP技术,是综合大量用户的需求,经过充分的用户论证的基础上开发出来的,独特的即时信息、短信、电子邮件系统、完善的工作流、数据库安全备份等功能使得信息在企业内部传递效率极大提高,信息传递过程中耗费降到最低。办公人员得以从繁杂的日常办公事务处理中解放出来,参与更多的富于思考性和创造性的工作。系统力求突出体系结构简明
语法
try {
print "this is our try block";
throw new Exception();
}catch (Exception $e) {
print "something went wrong, caught yah! n";
}finally {
print "this part is always executed";
}Example
的中文翻译为:示例
After throw (It will never be executed)"; } } // When Exception has been thrown by try block catch(Exception $e){ echo "
Exception Caught", $e->getMessage(); } //this block code will always executed. finally{ echo "
Final block will be always executed"; } } // Exception will not be rised here printdata(0); // Exception will be rised printdata(6); ?>
输出
Final block will be always executed Exception CaughtNumber is six. Final block will be always executed
注意
要处理异常,程序代码必须位于 try 块内。每次尝试必须至少有一个相应的 catch 块。多个catch块可用于捕获不同类别的异常。










