thinkphp6不能用redirect重定向是什么情况?

2021-11-12,

下面thinkphp框架教程栏目将给大家讲介绍关于thinkphp6不能用redirect重定向的问题,希望对需要的朋友有所帮助!

/2021/11/690f412d.jpg

TP6在__construct_initialize中无法使用redirect重定向?

说明

目前版本 return redirect('index/index'); 在__construct和_initialize无法使用,可以安装之前的代码方便使用

安装

composer require liliuwei/thinkphp-jump

用法示例

<?php
namespace app\controller;
class Index 
{
    use \liliuwei\think\Jump; 
    public function index()
    {
        //return $this->error('error');
        //return $this->success('success','index/index');
        //return $this->redirect('/admin/index/index');
        return $this->result(['username' => 'liliuwei', 'sex' => '男']);  
    }
}

推荐:《最新的10个thinkphp视频教程》

以上就是thinkphp6不能用redirect重定向是什么情况?的详细内容,更多请关注北冥有鱼其它相关文章!

本文转载自【PHP中文网】,希望能给您带来帮助,苟日新、日日新、又日新,生命不息,学习不止。

《thinkphp6不能用redirect重定向是什么情况?.doc》

下载本文的Word格式文档,以方便收藏与打印。