tp5 Controller 前置方法

使用前必须先继承Controller
class Address extends Controller
{
    protected $beforeActionList = [
        //执行second,third之前先执行first  执行third之前先执行first,second
        'first' => ['only' => 'second,third']
    ];

    //API接口的前置方法  执行顺序 i=1
    public function first()
    {
        echo 'first';
    }
    //API接口    i=2
    public function second()
    {
        echo 'second';
}
//i=3
public function third(){
    echo 'third';
}

猜你喜欢

转载自blog.csdn.net/weixin_37914752/article/details/79794722