This article mainly introduces the thinkphp framework using redirect to implement page redirection method, combined with an example of the thinkphp redirect for page redirection of the relevant operational skills and considerations, the need for friends can refer to the following
The example in this paper describes how the thinkphp framework uses redirect to implement page redirection. Share to everyone for your reference, as follows:
Thinkphp Redirect Method
The Thinkphp Redirect method enables page redirection (jump) functionality. The redirect method syntax is as follows:
$this->redirect(string url, array params, int delay, string msg)
Parameter description:
Parameters |
Description |
Url |
must, redirect the URL expression. |
Params |
Optional, additional URL parameters. |
Delay |
Optional, redirect delay, in seconds. |
Msg |
Optionally, redirect the prompt message. |
Thinkphp REDIRECT Instances
In the index module, in the index method, redirect to the select operation for this module:
Class Indexaction extends Action{public function index () {$this->redirect (' select ', Array (' status ' =>1), 3, ' page jump ~'); 3 Seconds}}
Some common examples of redirect redirects are:
No delay, direct redirect $this->redirect (' select ', Array (' status ' =>1));//delay jump, but without parameters, output default prompt $this->redirect (' select ', ' ', 3);//redirect to other module operations $this->redirect (' Public/login ');//redirect to other grouping $this->redirect (' Admin-public/login ');
Tips:
1. When the delay jumps, you must enter the params parameter (can be empty), that is, delay must appear on the 3rd bit.
2. If there is a problem with the URL after jumping, because the redirect method calls U method to generate the post-jump address, this time can test the U method to generate the correct address, and then check the system configuration.
Articles you may be interested in:
A variety of ways to include a specified string in a PHP string
PHP Framework CodeIgniter uses Redis to explain
Examples of TCP server and client functions implemented by PHP programming