主页 > PHP | WEB开发 > 关于PHP判断浏览器语言

关于PHP判断浏览器语言

2010 年 12 月 06 日 一条评论
<?php
if ($_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-CN' || $_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-cn'){

	echo("<meta http-equiv='refresh' content = '0;URL = http://zh-cn.xcomm.cn'>;");

}elseif ($_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-TW' || $_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-tw'){

	echo("<meta http-equiv='refresh' content = '0;URL = http://fan.xcomm.cn'>;");

}elseif ($_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-HK' || $_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-hk'){

	echo("<meta http-equiv='refresh' content = '0;URL = http://fan.xcomm.cn'>;");

}elseif ($_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-MO' || $_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-mo'){

	echo("<meta http-equiv='refresh' content = '0;URL = http://fan.xcomm.cn'>;");

}elseif ($_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-SG' || $_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-sg'){

	echo("<meta http-equiv='refresh' content = '0;URL = http://fan.xcomm.cn'>;");

}elseif ($_SERVER['HTTP_ACCEPT_LANGUAGE']=='en' || $_SERVER['HTTP_ACCEPT_LANGUAGE']=='zh-sg'){

	echo("<meta http-equiv='refresh' content = '0;URL = http://en.xcomm.cn'>;");

}else{
	
	echo("<meta http-equiv='refresh' content = '0;URL = http://zh-cn.xcomm.cn'>;");

}
?>

这段为什么在FF中不管是英文还是中文只会跳到最后 ELSE 的 URL 中去,判断完全失效,为什么??
因为firefox、chrome……$_SERVER['HTTP_ACCEPT_LANGUAGE']的值类似于:zh-CN,zh;q=0.8

Tags: PHP

发表评论

电子邮件地址不会被公开。 必填项已用*标注


*

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>