(编辑:jimmy 日期: 2026/1/1 浏览:2)
前言
本文介绍的是在PHP中用header("location:test.php")进行跳转要注意以下几点,有助于解决一些新手经常遇到的问题
一、location和“:”号间不能有空格,否则会出错。
二、在用header前不能有任何的输出。
三、header后的PHP代码还会被执行。
下面是和asp中重定向response.redirect的比较:
例1:
response.redirect "../test.asp"
header("location:../test.php");
两者区别:
asp的redirect函数可以在向客户发送头文件后起作用.
如
<html><head></head><body> <%response.redirect "../test.asp"%> </body></html>
查是php中下例代码会报错:
<html><head></head><body> <"location:../test.php"); "htmlcode"><"location:../test.php"); "color: #ff0000">例2:
asp中
<html><head></head><body> <% response.redirect "../a.asp" response.redirect "../b.asp" %> </body></html>结果是重定向a.asp文件.
php呢"htmlcode">
<"location:../a.php"); header("location:../b.php"); "htmlcode">if(...) header("..."); else { ... }但是我们可以简单的用下面的方法:
if(...) { header("...");exit();}还要注意的是,如果是用
Unicode(UTF-8)编码时也会出现问题,需要调整缓存设置.
<[email=%@]%@LANGUAGE="VBSCRIPT[/email]" CODEPAGE="936"%> <%if Request.ServerVariables("SERVER_NAME")="s.jb51.net" then response.redirect "news/index.htm" else%> <%end if%> <script> var url = location.href; if(url.indexOf('http://www.devdao.com/')!=-1)location.href='/index/index.htm'; if(url.indexOf('http://www.knowsky.com/')!=-1)location.href='/index1/index.htm'; if(url.indexOf('http://www.google.com/')!=-1)location.href='/cn/index.asp'; if(url.indexOf('http://www.baidu.com/')!=-1)location.href='/cn/index.asp'; </script>总结
以上就是这篇文章的全部内容了,希望能对大家的学习或者工作带来一定的帮助,如果有疑问大家可以留言交流。
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。