首页›MVC 核心›跳转方法族
跳转方法族
success / error 中间跳转页、redirect 301 跳转、quit 异常退出
本页内容
- 方法清单
- 模板配置
- 注意事项
方法清单
| 方法 | 签名 | 行为 |
|---|---|---|
success | success($msg="ok",$timer=0,$url=null) | 渲染 TEMPLATE_SUCCESS 模板(msg/timer/url 参数),经 returnLayout 后 Code200 flush |
error | error($msg="error",$timer=0,$url=null) | 渲染 TEMPLATE_ERROR 模板,Code200 flush(HTTP 200 而非 404) |
redirect | redirect($path) | Code301 + location 头 flush;空路径抛异常防死循环 |
quit | quit($message) | new Exception($message)->quit() |
模板配置
| 配置 | 默认 | 说明 |
|---|---|---|
TEMPLATE_SUCCESS | {@CORE}/Template/success | 成功中间页(实际文件 success.template) |
TEMPLATE_ERROR | {@CORE}/Template/error | 错误中间页(实际文件 error.template) |
典型用法
// 中间页跳转(模板控制倒计时与链接)
return $this->success("保存成功", 1, url("Index/Index"));
return $this->error("参数错误", 3, url("Index/Index"));
// 301 永久跳转
$this->redirect(url("Home/Index"));
// 直接终止
$this->quit("无权限访问");注意事项
success/error 使用 return 或不 return 均可——内部已经 flush+exit;模板文件不存在会抛异常终止。
KuoqiPHP v1.05 · 离线静态文档 · 界面基于 KuoqiUI ·
返回首页