Home  >  Article  >  php教程  >  网页只允许中国用户访问

网页只允许中国用户访问

WBOY
WBOYOriginal
2016-06-07 11:45:141163browse

网页只允许中国用户访问
$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);<br> //获取访客语言,是HTTP头信息的ACCEPT_LANGUAGE的前两个字符<br> if($language != 'zh'){<br> //zh是中文,包括zh-CN简体中文和zh-TW正体中文<br> header("Location: /yourpage.html");<br> //这句代码是将用户转向到根目录的yourpage.html这里<br> exit;<br> //然后退出<br> } $language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);
if($language == 'zh'){
echo '

Statement:
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