【PHP】TP6 initialize方法里面重定向

小破孩
2022-06-23 / 0 评论 / 112 阅读 / 正在检测是否收录...
    class MyBase extends BaseController
    {
        public function initialize()
        {
            parent::initialize(); // TODO: Change the autogenerated stub
            if(input('is_intercept') == true){
                return $this->redirect('http://www.slong.ink', 302);
            }
        }
    
        // 重定向
        public function redirect(...$arg) {
            throw new \think\exception\HttpResponseException(redirect(...$arg));
        }
    }
0

评论 (0)

取消