用PHP怎么判断用户所用浏览器以及浏览器版本
3个回答
展开全部
<?php
/** +--------------------------------------------+
Author: Paul
Copyright (c) 16/3/2011
+--------------------------------------------+ */
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Maxthon')) {
$browser = 'Maxthon';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8.0')) {
$browser = 'MSIE 8.0';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.0')) {
$browser = 'MSIE 7.0';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0')) {
$browser = 'MSIE 6.0';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'NetCaptor')) {
$browser = 'NetCaptor';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape')) {
$browser = 'Netscape';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx')) {
$browser = 'Lynx';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Opera')) {
$browser = 'Opera';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror')) {
$browser = 'Konqueror';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox')) {
$browser = 'Firefox';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'],'Safari')) {
$browser = 'Safari';
} else {
$browser = 'other';
}
echo $browser;
?>
/** +--------------------------------------------+
Author: Paul
Copyright (c) 16/3/2011
+--------------------------------------------+ */
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Maxthon')) {
$browser = 'Maxthon';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8.0')) {
$browser = 'MSIE 8.0';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.0')) {
$browser = 'MSIE 7.0';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0')) {
$browser = 'MSIE 6.0';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'NetCaptor')) {
$browser = 'NetCaptor';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape')) {
$browser = 'Netscape';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx')) {
$browser = 'Lynx';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Opera')) {
$browser = 'Opera';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror')) {
$browser = 'Konqueror';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox')) {
$browser = 'Firefox';
} elseif(strpos($_SERVER['HTTP_USER_AGENT'],'Safari')) {
$browser = 'Safari';
} else {
$browser = 'other';
}
echo $browser;
?>
展开全部
('/MSIE\s+6/',$_SERVER['HTTP_USER_AGENT'])){
header("Location: a.php");
}else{
header("Location: b.php");
}
?>
希望对你有帮助
header("Location: a.php");
}else{
header("Location: b.php");
}
?>
希望对你有帮助
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$_SERVER["HTTP_USER_AGENT"];
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询