public function actionMixins() { $person = new Person(); $myBehavior = new MyBehavior(); $myBehavior2 = new MyBehavior2(); $person->attachBehaviors(['myBeh' => $myBehavior, 'myBeh2' => $myBehavior2]); echo $person->hobby; echo $person->message; /*print_r($myBehavior->owner); print_r($person->getBehavior('myBeh'));*/ /*移除对象*/ /*$person->detachBehavior('myBeh'); $person->detachBehaviors();*/ $person->test(); }