Home > Backend Development > PHP Tutorial > PHP检测客户端用户语言函数

PHP检测客户端用户语言函数

WBOY
Release: 2016-06-20 13:03:32
Original
1293 people have browsed it

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 />}
Copy after login


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