Home > Backend Development > PHP Tutorial > How to automatically jump to Chinese and English pages in php_PHP tutorial

How to automatically jump to Chinese and English pages in php_PHP tutorial

WBOY
Release: 2016-07-13 10:23:00
Original
778 people have browsed it

How to automatically jump to Chinese and English pages in php

How to automatically jump to Chinese and English pages in php:

The code is as follows:

$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> //cut down to first 2 chars of country code  <br> var lang = lang.substr(0,2)  <br> // 英语  <br> if (lang == "en")  <br> window.location.replace(’url’)  <br> // 简体中文  <br> else if (lang == "zh-cn")  <br> window.location.replace(’url’)  <br> // 繁体中文  <br> else if (lang == "zh-tw")  <br> window.location.replace(’url’)  <br> // 德语  <br> else if (lang == "de")  <br> window.location.replace(’url’)  <br> // 除上面所列的语言  <br> else  <br> window.location.replace(’url’)  <br> </script>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/845124.htmlTechArticleHow to automatically jump to Chinese and English pages in php How to automatically jump to Chinese and English pages in php: The code is as follows: ? $lan= substr(?$HTTP_ACCEPT_LANGUAGE,0,5); if($lan==zh-cn) print(metahttp-equiv=refreshco...
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template