PHP弹出提示框并跳转到新页面即重定向到新页面_php技巧

WBOY
Release: 2016-05-17 08:50:23
Original
987 people have browsed it

这两天写一个demo,需要用到提示并跳转,主要页面要求不高,觉得没必要使用AJAX,JS等,于是研究了下怎么在PHP提示并跳转。

开始先是用了下面这种:

复制代码 代码如下:

echo "<script> alert('sucess');parent.location.href='//m.sbmmt.com/user/index'; </script>";

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

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

不过TP自带的不是弹出窗,于是自己改了改:
复制代码 代码如下:

echo "<script> alert('no loginid'); </script>";
echo "";

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

这里,莫离再给出两个直接跳转的方式:
复制代码 代码如下:

header("Location:".PSYS_BASE_URL."user/index");


复制代码 代码如下:

header("refresh:{$time};url={$url}");

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

最后还有一个问题,跳转代码后都跟上一个 return,因为还会执行后面的语句
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!