php根据用户语言跳转相应网页
更新时间:2015年11月04日 15:46:42 投稿:lijiao
这篇文章主要介绍了php根据用户语言跳转相应网页的方法,主要区分国内国外,感兴趣的小伙伴们可以参考一下
当来访者浏览器语言是中文就进入中文版面,国外的用户默认浏览器不是中文的就跳转英文页面。
<?php $lan = substr( $HTTP_ACCEPT_LANGUAGE,0,5); if ($lan == "zh-cn") print("<meta http-equiv='refresh' content = '0;URL = gb/index.htm'>"); else print("<meta http-equiv='refresh' content = '0;URL = eng/index.htm'>"); ?>
HTML网页根据来访这的浏览器语言不同自动跳转多语言页面
在 <head> </head> 之间加入如下代码。
以下为引用的内容:
<script> var type=navigator.appName if (type=="Netscape") var lang = navigator.language else var lang = navigator.userLanguage //cut down to first 2 chars of country code var lang = lang.substr(0,2) // 英语 if (lang == "en") window.location.replace('url') // 简体中文 else if (lang == "zh-cn") window.location.replace('url') // 繁体中文 else if (lang == "zh-tw") window.location.replace('url') // 德语 else if (lang == "de") window.location.replace('url') // 除上面所列的语言 else window.location.replace('url') </script>
以上就是PHP 判断用户语言跳转网页的全部内容,内容很简单,希望大家可以学以致用。
相关文章
PHP组合模式Composite Pattern优点与实现过程
这篇文章主要介绍了PHP组合模式Composite Pattern优点与实现,组合模式是一种结构型模式,它允许你将对象组合成树形结构来表示“部分-整体”的层次关系。组合能让客户端以一致的方式处理个别对象和对象组合2023-03-03php empty,isset,is_null判断比较(差异与异同)
做php开发时候,想必在使用:empty,isset,is_null 这几个函数时候,遇到一些问题。甚至给自己的程序带来一些安全隐患的bug。很多时候,对于isset,empty都认为差不多。因此开发时候,就没有注意,一段作为流程判断时候,就出现bug问题了。2010-10-10
最新评论