This article mainly introduces the method of using redirect to implement page redirection in the ThinkPHP framework. It analyzes the relevant operating skills and precautions for page redirection using redirect in thinkPHP based on examples. Friends in need can refer to the following
The example of this article describes how the ThinkPHP framework uses redirect to implement page redirection. Share it with everyone for your reference, the details are as follows:
ThinkPHP redirect method
ThinkPHP redirect method can realize page redirection (jump) Function. The redirect method syntax is as follows:
$this->redirect(string url, array params, int delay, string msg)
Parameter description:
Description | |
Required, redirect URL expression. | |
Optional, other URL parameters. | |
Optional, redirection delay, unit is seconds. | |
Optional, redirect prompt information. |
In the Index module index method, redirect to the select operation of this module:
class IndexAction extends Action{ public function index() { $this->redirect('select', array('status'=>1), 3, '页面跳转中~'); //3秒 } }
Some common redirect examples:
// 不延时,直接重定向 $this->redirect('select', array('status'=>1)); // 延时跳转,但不带参数,输出默认提示 $this->redirect('select', '', 3); // 重定向到其他模块操作 $this->redirect('Public/login'); // 重定向到其他分组 $this->redirect('Admin-Public/login');
1. When delaying a jump, the params parameter must be entered (can be empty), that is, delay must appear in the 3rd position.
2. If there is a problem with the redirected URL, because the redirect method calls the U method to generate the redirected address, you can test whether the address generated by the U method is correct and then check the system configuration. .
Articles you may be interested in:
Explanation on multiple methods of whether a specified string is included in a php stringphp framework CodeIgniter uses redis method to explainExplanation of TCP server and client function examples implemented by PHP programmingThe above is the detailed content of An example of how the ThinkPHP framework uses redirect to implement page redirection. For more information, please follow other related articles on the PHP Chinese website!