5.1构造函数问题

浏览:2202 发布日期:2017/12/27 分类:ThinkPHP5专区
//5.1
protected $beforeActionList = [
'first',
];
//---------------------------------------------
protected $auth_rule;
protected $auth_group;
protected $admins;


//------------5.0版本可以用------5.1 parent::__construct();报错-----------------
function __construct() {
parent::__construct();
$this->auth_rule=new \app\common\model\AuthRule();
$this->auth_group=new \app\common\model\AuthGroup();
$this->admins=new \app\common\model\Admins();
}


//------------5.1 要改成下面代码---------------------------------
protected function first()
{
$this->auth_rule=new \app\common\model\AuthRule();
$this->auth_group=new \app\common\model\AuthGroup();
$this->admins=new \app\common\model\Admins();
}


感觉号麻烦。。。
最佳答案
评论() 相关
后面还有条评论,点击查看>>