首页 > php开发 > php 页面跳转实现程序代码

php 页面跳转实现程序代码

下面我们总结了php中页面跳转几种方法,在php要实现跳转,就需要使用到header函数哦,下面我来一一介绍有需要的朋友可参考一下.

最简单的就是利用php header实现代码是:

实例代码如下:

<?php
header("Location:http://www.phprm.com/"); 

?>

通过get或post获取值再跳转有时候可以看到http://www.xxx.com/url.php?url=http://www.baidu.com,然后就跳转到百度.

如何用php实现这个url跳转呢?

只用简单的几行代码,就可以实现.

实例代码如下:

<?php
$url=$_GET["url"]; 
header("Location:".$url); 
?>

PHP 301转向实现代码,实例代码如下:

<?php
$url=""; 
header("HTTP/1.1 301 Moved Permanently"); 
header ("Location:$url"); 
?>

在ff看到状态代码容易吧.要测试就用curl这个小软件来检查.

#curl -I 
HTTP/1.0 301 Moved Permanently
Date: Tue, 06 May 2008 06:27:39 GMT
Server: apache
Location:


永久链接:http://www.phprm.com/develop/fs2284.html

转载随意!带上文章地址吧。

标签:php 程序代码 页面跳转

相关文章

发表留言