Maison >développement back-end >tutoriel php >PHP检测客户端用户语言函数
function get_client_language($availableLanguages, $default='en'){<br /> if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {<br /> $langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);<br /> foreach ($langs as $value){<br /> $choice=substr($value,0,2);<br /> if(in_array($choice, $availableLanguages)){<br /> return $choice;<br /> }<br /> }<br /> } <br /> return $default;<br />}