页面跳转
1、方法存在的文件路径
TP5\thinkphp\library\traits\controller\Jump.php
成功跳转 $this->success();
失败跳转 $this->error();
2、以登录功能为例:
login.php
<?php namespace app\index\controller; use\think\Controller; class Login extends Controller{ public function login(){ return view(); } public function check(){ $username = $_POST['username']; $password = $_POST['password']; if($username=="admin"&&$password=="123"){ //$this->success(提示信息,跳转的URL地址(默认到登陆界面), //用户需要返回的数据,跳转时间) $this->success("成功","user/index","","1"); }else{ //$this->error(提示信息,跳转的URL地址(默认到登陆界面), //用户需要返回的数据,跳转时间) //$this->error("失败"); //redirect('跳转地址','其他参数',code,'隐士参数');重定向 $this->redirect('user/index',['id'=>100,'name'=>'abc']); } } //空操作 public function _empty(){ $this->redirect('index/index'); } } ?>
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有