thinkphp Framework uses redirect to implement page redirection Method Example explained

Source: Internet
Author: User
Tags php framework php programming
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.