PHP exception handling technology, top-level exception handler
PHP handles exceptions like Java, with Try{}catch () {}
The function used to define the top-level exception handler is
Set_exception_handler ("My_exception");
The my_expection here is a developer-defined exception handler, a top-level exception processor that handles exceptions only if there are no functions in the program to handle exceptions, and if the top-level exception handler is not defined, the system defaults the exception handler to handle the exception
To illustrate:
PhpSet_exception_handler("My_expection"); functionmy_expection () {Echo"This is the top exception handler"; } Try{Nohello ("Hello"); }Catch(Exception $e){ Throw $e; }functionNohello ($nohello) {if($nohello= = "Hello") {Throw New Exception("Cannot Enter Hello"); }Else{ Echo"Input succeeded"; } }?>
Reprinted from: http://blog.sina.com.cn/s/blog_641d5693010121cr.html