ThinkPHP框架让页面重定向方法总结

php中世界最好的语言
php中世界最好的语言 原创
2023-03-26 07:06:02 1713浏览

这次给大家带来ThinkPHP框架让页面重定向方法总结,ThinkPHP框架让页面重定向方法的注意事项有哪些,下面就是实战案例,一起来看一下。

ThinkPHP redirect 方法

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, '页面跳转中~'); //3秒
}
}

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

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

相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

推荐阅读:

CodeIgniter使用redis步骤详解

PHP编程实现TCP服务端与客户端功能步骤详解

以上就是ThinkPHP框架让页面重定向方法总结的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。