Analysis of redirect usage in ThinkPHP

不言
Release: 2023-03-30 07:32:02
Original
2862 people have browsed it

This article mainly introduces the usage of redirect in ThinkPHP. It analyzes various common operation techniques of redirection with examples. It has certain practical value. Friends in need can refer to it.

This article explains the examples of ThinkPHP Medium redirect usage. Share it with everyone for your reference. The specific analysis is as follows:

redirect The general syntax of redirection is: redirect(url,params=array(),delay=0,msg=''), assuming that the current is the default HOME group Aritcle module insert operation, some The example is as follows:

Copy codeThe code is as follows:

// 跳转到 edit 操作 $this->redirect('edit'); // 跳转到 UserAction下的edit 操作 $this->redirect('User/edit'); // 跳转到 Admin分组默认模块默认操作 $this->redirect('Admin/'); // 跳转到 Admin分组Index模块view操作 $this->redirect('Admin-Index/view'); // 跳转到 Admin分组Index模块view操作,uid参数为1,延迟3秒跳转 $this->redirect('Admin-Index/view', array('uid'=>1), 3,'页面跳转中~') // 跳转到 其他OtherApp项目(非分组)的Admin项目分组User模块view操作 $this->redirect('OtherApp://Admin-User/view');
Copy after login

The same as the URL access in the project group, the cross-group jump in redirect just has one more group The concept of project name.

Tips: Routing can be used in redirect. The parameter usage of the redirect method is consistent with the usage of the U function. You can refer to the relevant parts of the U function to generate URL addresses.

Related Recommended:

ThinkPHP R method example

The above is the detailed content of Analysis of redirect usage in ThinkPHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!