温馨提示×

php中的异常处理函数有哪些

PHP
养鱼的猫咪
128
2021-03-24 13:47:34
栏目: 编程语言

php中的异常处理函数有哪些

php中的异常处理函数有set_exception_handler函数

set_exception_handler函数作用:

php中set_exception_handler函数的作用是用于创建运行期间的用户自己的异常处理方法。

set_exception_handler函数语法:

set_exception_handler(exception_function)

参数:

exception_function:规定未捕获的异常发生时调用的函数。

set_exception_handler函数使用方法:

// 定义的异常处理函数

function myException($exception) {

echo "Exception: ", $exception->getMessage();

}

// 设置定义的异常处理函数

set_exception_handler("myException");

// 抛出异常

throw new Exception("Uncaught exception occurred!");

0