php根据用户语言跳转相应网页
网络编程 2021-07-05 09:09www.168986.cn编程入门
这篇文章主要介绍了php根据用户语言跳转相应网页的方法,主要区分国内国外,感兴趣的小伙伴们可以参考一下
当来访者浏览器语言是中文就进入中文版面,国外的用户默认浏览器不是中文的就跳转英文页面。
<?php $lan = substr( $HTTP_ACCEPT_LANGUAGE,0,5); if ($lan == "zh-") 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-") 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中的使用情况
下一篇:非常全面的php日期时间运算汇总
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程