Home>Article>PHP Framework> Use the redirect method to implement redirection in thinkphp

Use the redirect method to implement redirection in thinkphp

尚
forward
2020-04-05 09:10:45 5002browse

Use the redirect method to implement redirection in thinkphp

Redirection is often a request jump sent by the server to the outside; the intuitive feeling is that the URL address of the browser has changed significantly and the page cannot be returned. This article will introduce to you how to use the redirect method to implement redirection in thinkphp.

The redirect method of the Action class can implement the redirection function of the page.

The parameter usage of the redirect method is consistent with the usage of the U function, for example:

//重定向到New模块的Category操作 $this->redirect('New/category', array('cate_id' => 2), 5, '页面跳转中...');

The above usage is to jump to the category operation of the News module after staying for 5 seconds, and the page is jumping. words, the current URL address will be changed after redirection.

If you just want to redirect to a specified URL address, rather than to the operation method of a certain module, you can directly use the redirect method to redirect, for example:

//重定向到指定的URL地址 redirect('/New/category/cate_id/2', 5, '页面跳转中...')

Redirect method The first parameter is a URL address.

Recommended tutorial:thinkphp tutorial

The above is the detailed content of Use the redirect method to implement redirection in thinkphp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:oschina.net. If there is any infringement, please contact admin@php.cn delete