NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
# 控制器初始化 如果你的控制器类继承了`\think\Controller`类的话,可以定义控制器初始化方法`_initialize`,在该控制器的方法调用之前首先执行。 例如: ``` namespace app\index\controller; use think\Controller; class Index extends Controller { public function _initialize() { echo 'init'; } public function hello() { return 'hello'; } public function data() { return 'data'; } } ``` 如果访问 <http://localhost/index.php/index/Index/hello> 会输出 ``` init hello ``` 如果访问 <http://localhost/index.php/index/Index/data> 会输出 ``` init data ```