PHP set_exception_handler() 函数
PHP 教程
· 2019-01-24 16:11:34
定义和用法
set_exception_handler() 函数设置用户自定义的异常处理函数。
该函数用于创建运行期间的用户自己的异常处理方法。
该函数返回旧的异常处理程序,如果失败则返回 NULL。
语法
set_exception_handler(exception_function)
| 参数 | 描述 |
|---|---|
| exception_function | 必需。规定未捕获的异常发生时调用的函数。 该函数必须在调用 set_exception_handler() 函数之前定义。这个异常处理函数需要需要一个参数,即抛出的 exception 对象。 |
提示和注释
提示:在这个异常处理程序被调用后,脚本会停止执行。
实例
<?php
function myException($exception)
{
echo "<b>Exception:</b> " , $exception->getMessage();
}
set_exception_handler('myException');
throw new Exception('Uncaught Exception occurred');
?>
上面代码的输出如下所示:
Exception: Uncaught Exception occurred
点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html
Numerical Methods and Methods of Approximation in Science and En
Karan Surana / CRC Press / 2018-10-31
ABOUT THIS BOOK Numerical Methods and Methods of Approximation in Science and Engineering prepares students and other readers for advanced studies involving applied numerical and computational anal......一起来看看 《Numerical Methods and Methods of Approximation in Science and En》 这本书的介绍吧!