当前位置:Gxlcms > PHP教程 > 怎么获取手机型号

怎么获取手机型号

时间:2021-07-01 10:21:17 帮助过:53人阅读

如何获取手机型号?
我想获取登录用户的终端型号,
作出如下的统计。
也试过了moblie_detect类,
但是这个类里面有的手机型号不全,而且没有小米,华为等等的型号,
我自己找又找不到具体手机的型号。
我最终是要获取手机的品牌

------解决思路----------------------

$user_agent = $_SERVER['HTTP_USER_AGENT'];
if (stripos($user_agent, "iPhone")!==false) {
$brand = 'iPhone';
} else if (stripos($user_agent, "SAMSUNG")!==false
------解决思路----------------------
stripos($user_agent, "Galaxy")!==false
------解决思路----------------------
strpos($user_agent, "GT-")!==false
------解决思路----------------------
strpos($user_agent, "SCH-")!==false
------解决思路----------------------
strpos($user_agent, "SM-")!==false) {
$brand = '三星';
} else if (stripos($user_agent, "Huawei")!==false
------解决思路----------------------
stripos($user_agent, "Honor")!==false
------解决思路----------------------
stripos($user_agent, "H60-")!==false
------解决思路----------------------
stripos($user_agent, "H30-")!==false) {
$brand = '华为';
} else if (stripos($user_agent, "Lenovo")!==false) {
$brand = '联想';
} else if (strpos($user_agent, "MI-ONE")!==false
------解决思路----------------------
strpos($user_agent, "MI 1S")!==false
------解决思路----------------------
strpos($user_agent, "MI 2")!==false
------解决思路----------------------
strpos($user_agent, "MI 3")!==false
------解决思路----------------------
strpos($user_agent, "MI 4")!==false
------解决思路----------------------
strpos($user_agent, "MI-4")!==false) {
$brand = '小米';
} else if (strpos($user_agent, "HM NOTE")!==false
------解决思路----------------------
strpos($user_agent, "HM201")!==false) {
$brand = '红米';
} else if (stripos($user_agent, "Coolpad")!==false
------解决思路----------------------
strpos($user_agent, "8190Q")!==false
------解决思路----------------------
strpos($user_agent, "5910")!==false) {
$brand = '酷派';
} else if (stripos($user_agent, "ZTE")!==false
------解决思路----------------------
stripos($user_agent, "X9180")!==false
------解决思路----------------------
stripos($user_agent, "N9180")!==false
------解决思路----------------------
stripos($user_agent, "U9180")!==false) {
$brand = '中兴';
} else if (stripos($user_agent, "OPPO")!==false
------解决思路----------------------
strpos($user_agent, "X9007")!==false
------解决思路----------------------
strpos($user_agent, "X907")!==false
------解决思路----------------------
strpos($user_agent, "X909")!==false
------解决思路----------------------
strpos($user_agent, "R831S")!==false
------解决思路----------------------
strpos($user_agent, "R827T")!==false
------解决思路----------------------
strpos($user_agent, "R821T")!==false
------解决思路----------------------
strpos($user_agent, "R811")!==false
------解决思路----------------------
strpos($user_agent, "R2017")!==false) {
$brand = 'OPPO';
} else if (strpos($user_agent, "HTC")!==false
------解决思路----------------------
stripos($user_agent, "Desire")!==false) {
$brand = 'HTC';
} else if (stripos($user_agent, "vivo")!==false) {
$brand = 'vivo';
} else if (stripos($user_agent, "K-Touch")!==false) {
$brand = '天语';
} else if (stripos($user_agent, "Nubia")!==false
------解决思路----------------------
stripos($user_agent, "NX50")!==false
------解决思路----------------------
stripos($user_agent, "NX40")!==false) {
$brand = '努比亚';
} else if (strpos($user_agent, "M045")!==false
------解决思路----------------------
strpos($user_agent, "M032")!==false
------解决思路----------------------
strpos($user_agent, "M355")!==false) {
$brand = '魅族';
} else if (stripos($user_agent, "DOOV")!==false) {
$brand = '朵唯';
} else if (stripos($user_agent, "GFIVE")!==false) {
$brand = '基伍';
} else if (stripos($user_agent, "Gionee")!==false
------解决思路----------------------
strpos($user_agent, "GN")!==false) {
$brand = '金立';
} else if (stripos($user_agent, "HS-U")!==false
------解决思路----------------------
stripos($user_agent, "HS-E")!==false) {
$brand = '海信';
} else if (stripos($user_agent, "Nokia")!==false) {
$brand = '诺基亚';
} else {
$brand = '其他手机';
}
echo $brand;
?>

人气教程排行