时间:2021-07-01 10:21:17 帮助过:20人阅读
public function __construct(){
parent::__construct();
}
public function test(){
echo "自动调用父类的构造方法";
}
public function test2(){
echo "人为控制不去调用父类的构造方法";
}
}
namespace Home\Common;
use Think\Controller;
class BBaseController extends Controller{
public static $login = true;//对某些访问公开
public function __construct(){
parent::__construct();
$this->initialize();
}
public function initialize(){
if(!session("admin_home_user")){
$this->error("您还没有登录,请登录","/Home/login",'3');
}
}
}
namespace Home\Controller;
use Home\Common\BBaseController;
class IndexController extends BBaseController{
public function __construct(){
parent::__construct();
}
public function test(){
echo "自动调用父类的构造方法";
}
public function test2(){
echo "人为控制不去调用父类的构造方法";
}
}
namespace Home\Common;
use Think\Controller;
class BBaseController extends Controller{
public static $login = true;//对某些访问公开
public function __construct(){
parent::__construct();
$this->initialize();
}
public function initialize(){
if(!session("admin_home_user")){
$this->error("您还没有登录,请登录","/Home/login",'3');
}
}
}