1. I want to implement the plug-in mechanism in my blog. The problem I am facing now is to add hooks on many nodes of the program and then execute the calls on the hooks.
2. But I have a question: how to pass data to the call on the hook? Pass it directly with parameters? I think this is too rigid. Is there a flexible way? Or use global?
3. I have been struggling with this problem for a long time, please answer ^-^
1. I want to implement the plug-in mechanism in my blog. The problem I am facing now is to add hooks to many nodes of the program and then execute the calls on the hooks.
2. But I have a question: how to pass data to the call on the hook? Pass it directly with parameters? I think this is too rigid. Is there a flexible way? Or use global?
3. I have been struggling with this problem for a long time, please answer ^-^
It is both rigid and standardized. Making a hook has relatively clear parameters, which is better for program maintainability and scalability. Furthermore, your incoming parameters are variable, and you can achieve whatever you want through an array encapsulation. Parameter form.