What is a hook? what is the function of hook? everyone knows that almost all php video lectures, including books, do not mention the Hook concept at all. However, it is often used in actual projects, so sometimes I feel that the gap in teaching practice has always been the biggest problem for Chinese people. I have never used it to talk about it, but I have never mentioned it.
After complaining, we have to face up to the grim reality. The question is, what is the hook?
Reply to discussion (solution)
Hook hooks. a set of hooks are hooks.
Hooks is a title for mounting user functions in Microsoft operating systems.
Called callable in php, the callable structure and callback function
This course should be taught.
Hook hooks. a set of hooks are hooks.
Hooks is a title for mounting user functions in Microsoft operating systems.
Called callable in php, the callable structure and callback function
This course should be taught.
Can you not use concepts to explain the concept? I didn't understand the concept in plain words. you can use this concept to explain it again.
In short, hooks are programs. These programs can be called at specific times.
Since you use the CI framework, you should know that there are some special time points in the framework initialization process, such
(1) time before framework initialization.
(2) time point before Controller initialization
(3) time points after the controller is running
Of course there are other time points.
At every point in time, you can bury some hooks (a program or a function ). In the framework, there will be a class library dedicated to hook processing (such as hooks in CI. php), The Hook class will check whether there is a specific Hook at a specific point in the program running, if there is a Hook, execute this Hook.
After talking about this, it may be a bit abstract. For example:
The whole process of your going home from work is a framework execution process. normally, you can go home directly after work. If your mom calls you and says that if you pass by the Post Office, there is a courier from another house and take it home, this process is similar to a hook (check the hook, if yes ).
If you have done some front-end work, this hook is like the "event-driven" mode.