1.构造函数:
控制器类必须继承了\think\Controller类,才能使用:
方法_initialize
代码:
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';
}
}
2.前置方法:
['except' => '方法名,方法名']:
表示这些方法不使用前置方法,
['only' => '方法名,方法名']:
表示只有这些方法使用前置方法。
*****分割线****
beforeActionList属性可以指定某个方法为其他方法的前置操作;
即执行之前执行;
代码:
namespace app\lian\controller;
use think\Controller;
use think\Db;
use think\Request;
cl