Home > Backend Development > PHP Tutorial > php自动跳转中英文页面_PHP

php自动跳转中英文页面_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 12:24:40
Original
680 people have browsed it

PHP代码:

$lan = substr(?$HTTP_ACCEPT_LANGUAGE,0,5);
if ($lan == "zh-cn")
print("");
else
print("");
?>

HTML网页根据来访这的浏览器语言不同自动跳转多语言页面

在 

  之间加入如下代码。

<script> <BR>var type=navigator.appName <BR>if (type=="Netscape") <BR>var lang = navigator.language <BR>else <BR>var lang = navigator.userLanguage <br><br>//cut down to first 2 chars of country code <BR>var lang = lang.substr(0,2) <br><br>// 英语 <BR>if (lang == "en") <BR>window.location.replace('url') <br><br>// 简体中文 <BR>else if (lang == "zh-cn") <BR>window.location.replace('url') <br><br>// 繁体中文 <BR>else if (lang == "zh-tw") <BR>window.location.replace('url') <br><br>// 德语 <BR>else if (lang == "de") <BR>window.location.replace('url') <br><br>// 除上面所列的语言 <BR>else <BR>window.location.replace('url') <br><br></script>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template