PHP判断客户端浏览器类型
代码如下
<?php/**
* 判断浏览器名称和版本
*/
functionget_user_browser()
{
if (empty($_SERVER["HTTP_USER_AGENT"])) {
return"error!";
}
if ((strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") == false) && (strpos($_SERVER["HTTP_USER_AGENT"], "Trident") !== FALSE)) {
return"Internet Explorer 11.0";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE 10.0") != false) {
return"Internet Explorer 10.0";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE 9.0") != false) {
return"Internet Explorer 9.0";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE 8.0") != false) {
return"Internet Explorer 8.0";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE 7.0") != false) {
return"Internet Explorer 7.0";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE 6.0") != false) {
return"Internet Explorer 6.0";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "Edge") != false) {
return"Edge";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "360SE") != false) {
return"360SE";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "QQBrowser") != false) {
return"QQBrowser";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "Firefox") != false) {
return"Firefox";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "Chrome") != false) {
return"Chrome";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "Safari") != false) {
return"Safari";
}
if (strpos($_SERVER["HTTP_USER_AGENT"], "Opera") != false) {
return"Opera";
}
//微信浏览器
if (strpos($_SERVER["HTTP_USER_AGENT"], "MicroMessage") != false) {
return"MicroMessage";
}
}
以上是 PHP判断客户端浏览器类型 的全部内容, 来源链接: utcz.com/z/517003.html