The HOOK in the PHP write plug-in is just a word that someone else thinks. The term is nothing more than actually. in WINDOWS programming, HOOK = HOOK is a message mechanism.
Php-http://www.xishuophp.com/
The HOOK in the PHP write plug-in is just a word that someone else thinks. The term is nothing more than actually. in WINDOWS programming, HOOK = HOOK
It is a message mechanism. it means that when a mosquito bites you and your brain receives the message, it directs the body to get rid of it, or beat the mosquito. this brain nerve is a HOOK, the system receives user operations, while the HOOK monitors user input A that meets certain conditions, and the system receives A, while the HOOK defines to receive B. Then, if A is input, no operation is performed. when B is input, activate the HOOK to execute the PHP code plug-in HOOK. for example, if you add a plug-in, inform the HOOK of the plug-in information in advance, and then HOOK to monitor the user when the user calls the plug-in, HOOK is aware, so the plug-in function is implemented. if there is such a program: function fun () {fun1 (); fun2 ();}, the program runs fun1 () then run fun2 () and then fun.
However, if we want to make some changes to the function. For example, fun is a parsing function. we hope to provide a variety of parsing functions in the future, and we want to configure which function is used in the configuration file. At this time, we can use the hook power.
We can add a hook point H to function fun () {}, and configure the hook function before executing the function H. then we can parse it as needed. For example: $ h = config_item ("parser_fun"); // obtain the corresponding configuration information from the configuration file function fun ($ data) {global $ h; return $ h ();} in addition to this accident, PHP can also provide its own class based on the string, and then call a method of the class to pass some parameters, which is written for the PHP program, and later maintenance expansion has laid a solid foundation.
Class implementation method, roughly as follows: $ c = get_class_name (); // Obtain the class name $ m = get_method_name (); // Obtain the method name $ k = $ c-> $ m (); // A method of the execution class. the complete implementation of the hook should be called an event driver or an event trigger, an event is triggered when an event is monitored.