ThinkPHP

被继承文件:PublicController.class.php

<?php
namespace AdminController;
use ThinkController;

class PublicController extends Controller {
	// 如果使用原有构造函数,要在其中调用parent::__construct();
	// public function __construct() {
	// 	 parent::__construct();
	// 	 echo 456;die;
	// }
	
	// 可以直接使用 TP内置的构造函数_initialize(一个下划线)
	// public function _initialize() {
	// 	echo 123;die;
	// }
}

继承文件:IndexController.class.php

<?php
namespace AdminController;
use ThinkController;

class IndexController extends PublicController {
    public function index(){
    	// 注册模板
        $this->display('index');
    }
}
原文地址:https://www.cnblogs.com/KTblog/p/5695096.html