thinphp中$this->redirect与redirect重定向区别
来源:互联网 发布:蚊子为什么要吸血知乎 编辑:程序博客网 时间:2024/06/07 12:44
$this->redirect($this->indexUrl);
使用ThinkPHP快三天了,之前听说很简单,加上项目时间短,就没看文档,直接从别人的源代码开始学起了。
上手确实还算快,但最让我头疼的就是ThinkPHP的URL问题了,URL一会是这个,一会又变成那个了,尤其是我在重定向的时候,被搞得简直是要疯掉了。
问题:
$this->indexUrl =__ROOT__."/index.php/Admin/index";
$this-><span style="font-family: Arial, Helvetica, sans-serif;">redirect($this->indexUrl);</span>
当前URL为http://localhost/myproject/index.php/Home/Login
这段代码一执行,浏览器上的URL立马变成了http://localhost/myproject/index.php/Home/Loginmyproject/index.php/Home/index,
很明显,这次重定向的URL是原URL直接加上了传进去的URL。百度了一下,发现ThinkPHP有两种重定向手段,一种是利用Controller的$this->redirect()函数,另一种就是用$this->redirect()的原型函数redirect(string url, int delay, string msg),这里的url就是绝对路径了。一运行,浏览器中的URL果然变成了http://localhost/myproject/index.php/Home/index。
有了这两种重定向函数,就可以在相对路径与绝对路径中游刃有余了
0 0
- thinphp中$this->redirect与redirect重定向区别
- 重定向redirect与转发forward的区别
- 页面的转发(dispatcher)与重定向(redirect)的区别
- posturl 与redirect(即重定向)的区别
- 重定向redirect与转发forward的区别?
- forward(转发)与redirect(重定向)的区别
- forward(转发)与redirect(重定向)的区别
- forward和redirect的区别,rorward,redirect,转发与重定向
- Servlet API中redirect(重定向)与forward(转发)/include(包含)的区别
- 重定向方法 render, forward, redirect 区别
- struts2 重定向 redirect
- Redirect,网页重定向
- Struts2重定向(redirect)
- haproxy redirect 重定向
- redirect重定向
- Linux:重定向(redirect)
- 重定向redirect
- 重定向(redirect)与管道(pipe)
- JQuery获取和设置select下拉框的值
- jquery插件开发
- 火狐打开太慢,关闭时提示火狐崩溃了
- poj 1001 Exponentiation
- 清除图片缓存
- thinphp中$this->redirect与redirect重定向区别
- 展讯智能机sp6825平台射频校准后无法“save to flash”问题解决
- 关于数据库的设计方法
- (转载)散列冲突处理:开放定址法
- 数据库中Date类型的计算 DATEDIFF() 函数
- FMDB
- VBA第4课 IF条件函数的使用
- qsort与sort的区别
- 视频关键帧提取