Home  >  Article  >  php教程  >  PHP跳转代码的实现方法讲解

PHP跳转代码的实现方法讲解

WBOY
WBOYOriginal
2016-06-13 11:09:101120browse

PHP跳转代码默认文档设置1 :

  1.  ?php   
  2. switch ($_SERVER["HTTP_HOST"])   
  3. {   
  4. case "www.a.com":   
  5. header("location:a/index.php");   
  6. break;   
  7. case "www.b.com":   
  8. header("location:b/index.php");   
  9. break;   
  10. case "www.c.com":   
  11. header("location:c/index.php");   
  12. break;   
  13. }   
  14. ?>   


PHP跳转代码默认文档设置2 :
 

<ol class="dp-xml">
<li class="alt"><span><span class="tag"><span> ?php  </span></span></span></li>
<li>
<span>$</span><span class="attribute">HTTP_HOST</span><span>=$_SERVER['HTTP_HOST'];   </span>
</li>
<li class="alt">
<span>if(($</span><span class="attribute">HTTP_HOST</span><span>=="a.com")or<br>($</span><span class="attribute">HTTP_HOST</span><span>=="www.a.com"))  </span>
</li>
<li><span>{Header("Location:/index.html"); }  </span></li>
<li class="alt">
<span>elseif(($</span><span class="attribute">HTTP_HOST</span><span>=="b.net")or<br>($</span><span class="attribute">HTTP_HOST</span><span>=="www.b.net"))  </span>
</li>
<li><span>{Header("Location: /kangbite/"); }  </span></li>
<li class="alt">
<span>elseif(($</span><span class="attribute">HTTP_HOST</span><span>=="c.com")or<br>($</span><span class="attribute">HTTP_HOST</span><span>=="www.c.com"))  </span>
</li>
<li><span>{Header("Location: /c/"); }  </span></li>
<li class="alt"><span>else  </span></li>
<li><span>{}  </span></li>
<li class="alt">
<span class="tag">?></span><span>   </span>
</li>
</ol>

以上就是PHP跳转代码的具体代码实现方法。


Statement:
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