For uncaptured exceptions, the official website did not provide a demo, and I did not expect any exceptions. Could you help me write a simple example? Thank you!
For uncaptured exceptions, the official website did not provide a demo, and I did not expect any exceptions. Could you help me write a simple example? Thank you!
Reply content:
For uncaptured exceptions, the official website did not provide a demo, and I did not expect any exceptions. Could you help me write a simple example? Thank you!
It's easy to understand.
For example, you have registered two callbacks in a function. The sample code is as follows:
Function somefunc1 () {// some code... // Throw a exception throw new \ Exception ('I am a exception! ');} Function somefunc2 () {// some code... // Not throw a exception}
Exactly when you execute,Somefunc1 ()
The exception is thrown. At this time, you must:
Try {call_user_func ('somefunc1 ');} catch (\ Exception $ e) {echo $ e-> getMessage ();} // when an exception occurs, the following functions will continue to execute call_user_func ('somefunc2 ');
If you do not catch exceptions like above, the sample code is as follows:
Call_user_func ('somefunc1 '); // when an exception is thrown, the code will not continue executing call_user_func ('somefunc2 ');
Above.