ThinkPHP redirect 方法可以实现页面的重定向(跳转)功能。redirect 方法语法如下:

$this->redirect(string url, array params, int delay, string msg) 

参数说明

url-必须,重定向的 URL 表达式。

params-可选,其它URL参数。

delay-可选, 重定向延时,单位为秒。

msg-可选,重定向提示信息。

 

ThinkPHP redirect 实例

在 Index 模块 index 方法中,重定向到本模块的 select 操作:

class IndexAction extends Action{
    public function index(){
        $this->redirect('select', array('status'=>1), 3, '页面跳转中~');
    }
}

重定向后得到的 URL 可能为:http://www.5idev.com/index.php/Index/select/status/1

一些常用的 redirect 重定向例子:

// 不延时,直接重定向
$this->redirect('select', array('status'=>1));
// 延时跳转,但不带参数,输出默认提示
$this->redirect('select', '', 3);
// 重定向到其他模块操作
$this->redirect('Public/login');
// 重定向到其他分组
$this->redirect('Admin-Public/login');

相关文章:

  • 2022-12-23
  • 2021-07-30
  • 2021-06-29
  • 2022-12-23
  • 2021-08-05
  • 2021-12-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-28
  • 2022-12-23
相关资源
相似解决方案