Home > Backend Development > PHP Tutorial > PHP如何优雅地实现hook?

PHP如何优雅地实现hook?

WBOY
Release: 2016-06-06 20:42:54
Original
1082 people have browsed it

PHP如何优雅地实现hook?

回复内容:

PHP如何优雅地实现hook?

一般都是基于观察者模式 学习下原理基本就明白了

注册:"hook函数名"('事件名', 'callback', /* 其他的可优化的功能 优先级等*/)
触发: "hook函数名"('事件名')

用类也是一样的 无非是各种名字 注册有on、listen神马的 触发可以是fire trigger之类的

明白原理 这些东西就只是形式

可以参考wordpress的do_action()和apply_filters()函数

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template