Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1505334
  • 博文数量: 164
  • 博客积分: 2993
  • 博客等级: 少校
  • 技术积分: 1718
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-24 11:42
文章分类

全部博文(164)

文章存档

2014年(1)

2013年(36)

2012年(90)

2011年(37)

分类: Python/Ruby

2012-07-24 13:19:12

Sets the default exception handler if an exception is not caught within a try/catch block. Execution will stop after the exception_handler is called.

设置默认的异常处理函数,捕获没有用try/catch块处理的异常。当调用exception_hander时,程序停止执行。

  1. <?php
  2. function exception_handler($exception) {
  3.   echo "Uncaught exception: " , $exception->getMessage(), "\n";
  4. }

  5. set_exception_handler('exception_handler');

  6. throw new Exception('Uncaught Exception');
  7. echo "Not Executed\n";
  8. ?>


 

阅读(1749) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~