php自动跳转中英文页面

yipeiwu_com5年前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 cookie,session的使用与用户自动登录功能实现方法分析

本文实例讲述了PHP cookie,session的使用与用户自动登录功能实现方法。分享给大家供大家参考,具体如下: cookie的使用 //生成cookie //注释:setcoo...

php返回字符串中所有单词的方法

本文实例讲述了php返回字符串中所有单词的方法。分享给大家供大家参考。具体分析如下: 这段代码返回字符串中的所有单词,当$distinct=true时去除重复元素。代码如下: &...

分享8个最佳的代码片段在线测试网站

分享8个最佳的代码片段在线测试网站

有时候,我们需要测试一些代码片段,而电脑中没有安装针对该语言的运行环境,没关系,你可以在线测试它们。  本文为你带来 8 款非常好用的代码片段在线工具,帮助你快速、方便地测试、...

php中将时间差转换为字符串提示的实现代码

如微博 这看起来更加人性化,好吧,上代码 复制代码 代码如下: <?php class timeAgo { static $timeagoObject; private $rust...

php中get_meta_tags()、CURL与user-agent用法分析

本文实例分析了php中get_meta_tags()、CURL与user-agent用法。分享给大家供大家参考。具体分析如下: get_meta_tags()函数用于抓取网页中<m...