Home > PHP Framework > ThinkPHP > body text

Use the redirect method to implement redirection in thinkphp

Release: 2020-04-05 09:10:45
forward
5083 people have browsed it

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, '页面跳转中...');
Copy after login

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, '页面跳转中...')
Copy after login

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!

Related labels:
source:oschina.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template