Want to get UA in the language encoding information to achieve jump, function: If the UA contains non-ZH-CN encoding, jump, not set the language information does not jump,
Not the program, check the function of their own afternoon has not been successful in the experiment, the condition plus cycle dizzy, output a bunch of no, Daniel Calf help, thank you!
$ua = $_server[' http_user_agent '); $lang = Array ("Af-za", "Sq-al", "Ar-dz", "Ar-bh", "Ar-eg", "Ar-iq", "Ar-jo", "ar-kw", "ar-lb", "ar-ly", "Ar-ma", "Ar-om", " Ar-qa "," Ar-sa "," Ar-sy "," Ar-tn "," Ar-ae "," Ar-ye "," Hy-am "," Az azeriaz-az-cyrl "," Az-az-latn Azeri "," Eu-es "," be-by "," BG-BG "," Ca-es "," Zh-hk "," Zh-mo "," ZH-CN "," Zh-chs "," ZH-SG "," ZH-TW "," Zh-cht "," Hr-hr "," Cs-cz "," DA-DK "," DIV-MV "," Nl-be "," nl-nl "," En-au "," En-bz "," En-ca "," EN-CB "," En-ie "," EN-JM "," En-nz "," en-ph "," En-za "," En-tt "," EN-GB "," en-US " , "En-zw", "Et-ee", "Fo-fo", "Fa-ir", "Fi-fi", "fr-be", "Fr-ca", "Fr-fr", "Fr-lu", "FR-MC", "Fr-ch", "Gl-es", "Ka-ge", " De-at "," De-de "," De-li "," De-lu "," De-ch "," El-gr "," gu-in "," He-il "," hi-in "," Hu-hu "," Is-is "," Id-id "," it-it "," It-ch " , "JA-JP", "kn-in", "Kk-kz", "kok-in", "Ko-kr", "Ky-kz", "Lv-lv", "Lt-lt", "Mk-mk", "ms-bn", "Ms-my", "mr-in", "Mn-mn", " Nb-no "," Nn-no "," PL-PL "," Pt-br "," pt-pt "," pa-in "," Ro-ro "," Ru-ru "," sa-in "," Sr-sp-cyrl "," Sr-sp-latn "," Sk-sk "," Sl-si "," Es-ar "," Es-bo "," Es-cl "," Es-co "," ES-CR "," es-do "," Es-ec "," ES-SV "," Es-gt "," Es-hn "," es-mx ","Es-ni "," Es-pa "," Es-py "," Es-pe "," ES-PR "," Es-es "," Es-uy "," Es-ve "," Sw-ke "," Sv-fi "," Sv-se "," Syr-sy "," ta-in "," Tt-ru "," te-in "," th-th "," Tr-tr "," Uk-ua "," UR-PK "," Uz-uz-cyrl "," Uz-uz-latn "," VI-VN "), for ($i =0; $i <136; $i + +) {if (is_ Numeric (Stripos ($ua, $lang [$i]) = = False) {echo "No";} Else{echo "Yes";}}
Reply to discussion (solution)
Isn't In_array better?
Demand is Chinese do not jump, non-Chinese jump?
The language used to get the client browser should be intercepted from $_server["Http_accept_language".
Give me a chestnut.
if (Preg_match ("/zh/i", substr ($_server[' http_accept_language '], 0, 4)) { echo "does not jump";} else { echo "jump";}
Language information in Http_accept_language instead of http_user_agent
Http_accept_language is actually a reflection of the default character set of the client operating system, regardless of what character set the user uses to browse your Web page
Who told you that Chinese browsers can't see websites in plain English?
First, Http_accept_language already mentioned
Second, the demand is non-zh code jump, you do not necessarily have all the possible list, with Stripos to determine once can
Finally, iterate through the array to try the foreach
Humbly everyone!!!
Keep on tossing first
Thank you all cows and cows, the experiment for a long time,
UA acquisition and browser acquisition are two ideas
All two needs to be done, and foreach works.
Many UA do have language information, not all, so you still need to judge all