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)
未经允许不得转载:主机测评网 » php中的异常处理函数有哪些
分享到: 更多 (0)