What does it mean php hook

To "hook" is not really familiar with this concept, recently saw a php use this mechanism to extend the framework of the project, it is probably to understand the next.

The so-called Hook mechanism, from the windows a technique that became popular in the programming. The main idea is ahead of where it may increase the functionality of burying (the default) a hook, the hook and no practical significance, when we need to modify or add logic to this place when the extended class or method to mount to this point can be.

The basic idea hook plugin mechanism:

In the project code, you think you want to extend (temporarily extended) place to put a hook function, and so on need to extend the time that the classes and functions need to be implemented to mount onto the hook, you can achieve expanded.

That sounds more general idea is to see an example of realization of a network.

The entire plug-in mechanism consists of three parts:

1.hook plug-in manager class: This is the core file is an application global Global object. It has three main responsibilities

1> listener has registered all plug-ins, plug-ins and instantiate these objects.

2> Register all plug-ins.

3> When hook condition is met, trigger the corresponding object methods.

2. The plug-in function to realize: This is mostly done by third-party developers, but we need to follow (Manager class definition) rules, this rule is provided for plug-in mechanism, due to the different mechanisms and different plug-ins.

3. trigger plug: that is the trigger condition hooks. This is a small piece of code placed where you need to call widget used to trigger this hook.

 

 

 

https://www.solves.com.cn/it/cxkf/yy/php/2019-11-25/8590.html

Guess you like

Origin www.cnblogs.com/ysbl/p/12650950.html