Home >php教程 >php手册 >PHP实现页面跳转

PHP实现页面跳转

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 09:43:32780browse


非常简单的一个demo,需要实现提示并跳转,主要页面要求不高,觉得没必要使用AJAX,JS等。

于是研究了一下在PHP提示并跳转。

开始使用如下跳转:
echo "<script> alert(&#39;sucess&#39;);parent.location.href=&#39;/user/index&#39;; </script>";

alert里面是提示的消息,href是提示后跳转的页面。

后来想起TP框架里面有个redirect()重定向的方法,就去看了看。

不过TP自带的不是弹出窗,于是修改为:

$url="http://www.jbxue.com";
echo "<script> alert(&#39;no loginid&#39;); </script>"; 
<em id="__mceDel">echo "<meta http-equiv=&#39;Refresh&#39; content=&#39;0;URL=$url&#39;>";</em>

$url就是要跳转的页面,同时,这个还能控制跳转时间,content后面的0就是表示0秒后跳转。

两个直接跳转的方式:

header("Location:".PSYS_BASE_URL."user/index"); 
和 
header("refresh:{$time};url={$url}");

这两种方式无提示,直接跳转。推荐下面一种。

最后还有一个问题,跳转代码后都跟上一个 return,因为还会执行后面的语句。

Statement:
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