How to jump to another page in PHP

不言
Release: 2023-03-25 16:36:02
Original
74438 people have browsed it

这篇文章主要介绍了关于PHP 页面跳转到另一个页面的方法,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

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

推荐手册php完全自学手册

一、用HTTP头信息

也就是用PHP的HEADER函数。

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

代码如下:

Copy after login

注意一下,"Localtion:"后面有一个空格。

二、用HTML标记

用HTML标记,就是用META的REFRESH标记,举例如下:

代码如下:

   
   
Copy after login

三、用脚本来实现

举例如下:

代码如下:

"; echo "location.href='$url'"; echo "-->"; ?>
Copy after login

下面是补充

第四种:

echo "< meta http-equiv=\\"Refresh\\" content=\\"秒数; url=跳转的文件或地址\\" > ";
Copy after login

其中:XX是秒数,0为立即跳转.refresh 是刷新的意思.Url 是要跳转到的页面.

第五种:

利用script实现

Copy after login

第六种:

利用script实现,所不同的是使用 open 语句.且可以限制原窗口还是父窗口,子窗口或者新窗口.

Copy after login

其中 更改\'_self\' 就可以实现跳转限制原窗口还是父窗口,子窗口或者新窗口.第七种:利用php自带函数发送头部信息

header("Location: Url");
Copy after login

速度最快,功能强大...但是有个问题必须指出:如果在使用这个函数前已经有html输出,哪怕是一个空格.

那么在页顶会显示错误信息..

相关文章推荐
1. PHP跳转页面的几种实现方法
2. PHP想要实现页面跳转功能具体怎么操作?(函数标签示例)
相关视频推荐
1. 独孤九贱(4)_PHP视频教程

The above is the detailed content of How to jump to another page in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
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!