Php 內网址自动转向

1、header函数使用location网页导向

利用header函数与HTTP的档头资讯一起使用的功能,header函数的使用必须在资料输出之前,所以要写在所有语法之前,包括资料输出或标签之前。

A、语法:header(“档头资讯名称:档头内容”);

B、范例:

(1)、导向到某一个网址<?php header("location: http://www.isharkfly.com")?>(2)、导向到目录的某一目录<?php header("location: simple.php")?>(3)、导向到「HTTP 404 - 找不到文档」的错误讯息<?php header("HTTP/1.0 404 Not Found");?>C、错误写法:

(1)、使用header之前不可有资料输出[code]<?php echo "错误写法"?>

<?php header("location: http://www.isharkfly.com")?>[/code](2)、使用header不可在Html 标签内[code] 错误写法 <?php header("location: http://www.many.com.tw")?> [/code]2、header函数使用refresh网页重读及网页导向

A、语法:

语法一:header(“refresh:秒数”)
语法二:header(“refresh:秒数”;url=导向的网址或目录档)

B、范例:

(1)、五秒后自动重新整理网页<?php header("refresh:5")?>(2)、五秒后导向到网址<?php header("refresh:5 ; url=http://www.isharkfly.com")?>