The usage of Set_exception_handler function in thinkphp, THINKPHPC function
This article describes the use of the Set_exception_handler function in thinkphp. Share to everyone for your reference. Here's how:
Function:
Copy the Code code as follows: String Set_exception_handler (callback $exception _handler)
Definition and Usage:
The Set_exception_handler () function sets the user-defined exception handling function.
This function is used to create the user's own exception handling method during runtime.
The function returns the old exception handler, or null if it fails.
Grammar:
Set_exception_handler (exception_function)
Parameters |
Description |
Error_function |
Necessary. Specifies the function that is called when an uncaught exception occurs. The function must be defined before calling the Set_exception_handler () function. This exception handler requires a parameter, the exception object that is thrown. |
Tips and Comments:
tip : After this exception handler is called, the script stops executing.
The same is seen in the TP code when the function found, I do not understand, I have not cared about these things before? (Wringing ing ... )
Continue to see how TP is achieved, er, why must use TP, hmm. Well, I'll move the example of the handbook in a moment.
Copy the Code Code as follows: Public function appexception ($e)
{
Halt ($e->__tostring ());
}
Set_exception_handler (Array (& $this, "Appexception"));
Oh, this is simple, right? Because I didn't give the implementation of the halt method, that's enough.
Then look at the examples in the manual,
Copy the Code code as follows: function Exception_handler ($exception) {
echo "uncaught exception:", $exception->getmessage (), "n";
}
Set_exception_handler (' Exception_handler ');
throw new Exception (' uncaught Exception ');
echo "Not Executedn";
In fact, Set_exception_handler is set to call which custom function when your program needs to throw an exception.
It's so simple.
Precautions:
Set_exception_handler ("MyException") can not only accept functions, but also accept the methods of the class (public static methods and public non-static methods can be), but need to be passed as an array, the first value of the array is "class name", the second parameter is "method name"
It is hoped that this article will be helpful to everyone's thinkphp framework design.
How to use PHP functions for thinkphp templates
That's how it's written. That's right. {$create _time|date= ' y-m-d h:i:s ', # # #}, but $create_time should be a 11-digit number
Reference: doc.thinkphp.cn/manual/use_function.html
thinkphp Framework templates Use System functions
There are two ways to use//1, direct use of tags //2, use template tag {$vo. Name} {$vo. name|mb_strlen=0,20}
http://www.bkjia.com/PHPjc/904013.html www.bkjia.com true http://www.bkjia.com/PHPjc/904013.html techarticle The use of the Set_exception_handler function in thinkphp, the THINKPHPC function, describes the use of the Set_exception_handler function in thinkphp. Share to everyone for your reference. Specific ...