Home >PHP Framework >ThinkPHP >Redirect in TP5 implements redirection and jump with parameters
The following tutorial column will introduce you to the redirect method in TP5 to implement redirection and jump with parameters. I hope it will be helpful to friends in need! Redirection
The redirect method of the \think\Controller class can implement the redirection function of the page. The parameter usage of the redirect method is consistent with the usage of the Url::build method (refer to the URL generation part). For example:
//重定向到News模块的Category操作 $this->redirect('News/category', ['cate_id' => 2]);
The above usage is to jump to the category operation of the News module. Re- The current URL address will be changed after orientation.
Or redirect directly to a specified external URL address, for example:
//重定向到指定的URL地址 并且使用302 $this->redirect('http://thinkphp.cn/blog/2',302);Jump and redirection
can be used when redirecting Pass values through session flash memory data, for example $this->redirect('News/category', ['cate_id' => 2], 302, ['data' => 'hello']);
Using the redirect assistant function can also achieve more functions, for example, you can remember the current URL and then jump
redirect('News/category')->remember();
You need to jump to the last time When remembering the URL, use:
redirect()->restore();
Front-end reference
href="{:url(url,data)}
Back-end page jump
For example:
$this->success('批量数据添加成功', url('DataManagement/dataStatus',$data3));
The above is the detailed content of Redirect in TP5 implements redirection and jump with parameters. For more information, please follow other related articles on the PHP Chinese website!