1.构造函数:
控制器类必须继承了\think\Controller
类,才能使用:
方法_initialize
代码:
<?php namespace app\lian\controller;use think\Controller;use think\Db;use think\Request;class Index extends Controller { public function _initialize() { echo 'init|||'; } public function hello() { return 'hello'; } }
地址:http://localhost/index.php/lian/index/hello