众所周知,yii的三大特性是:属性.事件.行为,上一篇博文简单讲解了yii中的属性,本文接着讲讲yii的事件. 事件是代码解耦的一种方式,设计业务流程的一种模式.在yii2.0中,通过Yii\base\Component继承yii\base\Object,重载__get().__set()方法,引入了事件和行为,使得开发变得十分方便.然而,在方便开发的同时也牺牲了一定的效率,所以若不需要使用事件和行为,可不必继承Component而选择继承Object,Object的效率更接近原生的PHP类.…