Home > php教程 > PHP源码 > 12306_网页只允许中国用户访问

12306_网页只允许中国用户访问

PHP中文网
Release: 2016-05-25 17:08:09
Original
1189 people have browsed it

12306_网页只允许中国用户访问

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

2. [代码][PHP]代码

<?php
// http://blog.ddian.cn
$language = substr($_SERVER[&#39;HTTP_ACCEPT_LANGUAGE&#39;],0,2);
if($language == &#39;zh&#39;){
echo &#39;<noscript><noscript>&#39;;
}
?>
</body>
Copy after login

以上就是12306_网页只允许中国用户访问的内容,更多相关内容请关注PHP中文网(www.php.cn)!


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template