37702 2016-08-03 11:01:41 3125次浏览 0条评论 0 0 0
<?php 
class myBehavior extends yii\base\Behavior{
    public $property = '成员属性';
    public function method(){
        echo 'this is 成员方法';
    }
}

// 调用
$red = new Component;//或者继承Component的子类
$res = new myBehavior();
$com->attachBehavior('myBehavior','$myBehavior');
echo $red->property;
echo $red->method();

?>
    没有找到数据。
您需要登录后才可以评论。登录 | 立即注册