时间:2021-07-01 10:21:17 帮助过:21人阅读
Observed
->_observers =
attach(SplObserver ->_observers->attach(
detach(SplObserver ->_observers->detach(
(->_observers ->showMessage(
setName(->_name = ->
->
setAge(->age = (->_observers ->showAge(->_name,->
Observer
showMessage(SplSubject = ->(==='admin' '您好, ',,'欢迎您进入管理后台
' "你好, '' 你已经被添加到了用户列表
"
update(SplSubject
showAge(, "" = Observed();
= Observer();
->attach();
->setName('张三'); notify();
* 通过调用 $this->notify()就会调用 $observer->showMessage($this)方法,
* 即每个观察者对象的 showMessage($obj)方法;
->setName('admin'->setAge(24);
http://www.bkjia.com/PHPjc/440273.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/440273.htmlTechArticleObserved -_observers = attach(SplObserver -_observers-attach( detach(SplObserver -_observers-detach( ( -_observers -showMessage( setName( -_name = - - setAge( -age = ( -_observers...