Home > php教程 > php手册 > body text

PHP 页面跳转的三种方法汇总

WBOY
Release: 2016-06-21 08:57:02
Original
728 people have browsed it

如何在PHP中从一个页面重定向到另外一个页面呢?这里列出了三种办法,供参考。

如何在PHP中从一个页面重定向到另外一个页面呢?这里列出了三种办法,供参考。
一、用HTTP头信息
也就是用PHP的HEADER函数。PHP里的HEADER函数的作用就是向浏览器发出由HTTP协议规定的本来应该通过WEB服务器的控制指令,例如声明返回信息的类型("Context-type: xxx/xxx"),页面的属性("No cache", "Expire")等等。
用HTTP头信息重定向到另外一个页面的方法如下:


if (isset($url))
{
Header("HTTP/1.1 303 See Other");
Header("Location: $url");
exit; //from www.jzxue.com
}
?>
注意一下,"Localtion:"后面有一个空格。
二、用HTML标记
用HTML标记,就是用META的REFRESH标记,举例如下:


if (!isset($url)) exit;?>


";
echo "location.href='$url'";
echo "īpt>-->";
?>



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 Recommendations
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!