
Yii 行为是干什么的?
Yii行为是事件的升级版,所有的行为都是Behavior的子类,其作用是将相似事件句柄放在一起,在行为执行“attach()”方法的时候会将“events()”方法中返回的事件句柄进行绑定,这样做达到方面管理和扩展的目的。
示例代码
行者AI
行者AI绘图创作,唤醒新的灵感,创造更多可能
100 查看详情
/*** Raised right BEFORE the application processes the request.* @param CEvent $event the event parameter*/public function onBeginRequest($event){ $this->raiseEvent('onBeginRequest',$event);}/*** Runs the application.* This method loads static application components. Derived classes usually overrides this* method to do more application-specific tasks.* Remember to call the parent implementation so that static application components are loaded.*/public function run(){ if($this->hasEventHandler('onBeginRequest')) $this->onBeginRequest(new CEvent($this)); $this->processRequest(); if($this->hasEventHandler('onEndRequest')) $this->onEndRequest(new CEvent($this));}
推荐教程:《PHP教程》《Yii教程》
以上就是Yii 行为是干什么的?的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/355848.html
微信扫一扫
支付宝扫一扫