php自动跳转中英文页面
2023-06-13 09:14:01 时间
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>
<?
$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实现自动开启/关闭夜间模式
- PhpStorm 2022 for Mac(PHP集成开发) v2022.2.2激活版
- 一段经典的抽奖算法 for PHP版
- PHP namespace用法详解编程语言
- Redis实现长连接:PHP开发入门(redis长连接php)
- PHP轻松加载MySQL模块(php加载mysql模块)
- 使用PHP实现Redis快速构建应用(redis实例php)
- MySQL连接池:PHP提供的快速访问方式(mysql连接池php)
- PHP连接MSSQL数据库的方法和步骤(php如何连接mssql)
- PHP MySQL 开发构建实现功能多样的网站(php mysql 类)
- PHP如何实现与MSSQL的连接(要php链接mssql)
- 内存Redis自动优化PHP内存管理(redis自动释放php)
- php将bmp图片转为jpg等其他任意格式的图片
- 生成ubuntu自动切换壁纸xml文件的php代码
- PHP和Mysqlweb应用开发核心技术第1部分Php基础-1开始了解php
- php中CI操作多个数据库的代码
- php中使用__autoload()自动加载未定义类的实现代码
- IIS+fastcgi下PHP运行超时问题的解决办法详解
- 解析php类的注册与自动加载
- PHP中对缓冲区的控制实现代码