PHP可以用来实现许多种网页功能,那么在进页面跳转时,我们应当如何编写具体的代码呢?本文给出了两则PHP跳转代码的实际编写方法。#t#
PHP跳转代码默认文档设置1 :
- < ?php
- switch ($_SERVER["HTTP_HOST"])
- {
- case "www.a.com":
- header("location:a/index.php");
- break;
- case "www.b.com":
- header("location:b/index.php");
- break;
- case "www.c.com":
- header("location:c/index.php");
- break;
- }
- ?>
PHP跳转代码默认文档设置2 :
- < ?php
- $HTTP_HOST=$_SERVER['HTTP_HOST'];
- if(($HTTP_HOST=="a.com")or
($HTTP_HOST=="www.a.com"))- {Header("Location:/index.html"); }
- elseif(($HTTP_HOST=="b.net")or
($HTTP_HOST=="www.b.net"))- {Header("Location: /kangbite/"); }
- elseif(($HTTP_HOST=="c.com")or
($HTTP_HOST=="www.c.com"))- {Header("Location: /c/"); }
- else
- {}
- ?>
以上就是PHP跳转代码的具体代码实现方法。