《PHP實(shí)例:php根據(jù)用戶語言跳轉(zhuǎn)相應(yīng)網(wǎng)頁》要點(diǎn):
本文介紹了PHP實(shí)例:php根據(jù)用戶語言跳轉(zhuǎn)相應(yīng)網(wǎng)頁,希望對您有用。如果有疑問,可以聯(lián)系我們。
當(dāng)來訪者瀏覽器語言是中文就進(jìn)入中文版面,國外的用戶默認(rèn)瀏覽器不是中文的就跳轉(zhuǎn)英文頁面.
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網(wǎng)頁根據(jù)來訪這的瀏覽器語言不同自動(dòng)跳轉(zhuǎn)多語言頁面
在 <head> </head> 之間加入如下代碼.
以下為引用的內(nèi)容:
PHP教程
<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 判斷用戶語言跳轉(zhuǎn)網(wǎng)頁的全部內(nèi)容,內(nèi)容很簡單,希望大家可以學(xué)以致用.PHP教程
歡迎參與《PHP實(shí)例:php根據(jù)用戶語言跳轉(zhuǎn)相應(yīng)網(wǎng)頁》討論,分享您的想法,維易PHP學(xué)院為您提供專業(yè)教程。
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/8458.html