PHP获取手机型号与系统型号代码

PHP获取手机型号代码

<?php
$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;
?>

PHP获取系统型号代码

<?php
function userOS(){  
      $user_OSagent = $_SERVER['HTTP_USER_AGENT'];  
    if(strpos($user_OSagent,"NT 6.1")){  
        $visitor_os ="Windows 7";  
    } elseif(strpos($user_OSagent,"NT 5.1")) {  
      $visitor_os ="Windows XP (SP2)";  
    } elseif(strpos($user_OSagent,"NT 5.2") && strpos($user_OSagent,"WOW64")){  
      $visitor_os ="Windows XP 64-bit Edition";  
  } elseif(strpos($user_OSagent,"NT 5.2")) {  
        $visitor_os ="Windows 2003";  
  } elseif(strpos($user_OSagent,"NT 6.0")) {  
        $visitor_os ="Windows Vista";  
    } elseif(strpos($user_OSagent,"NT 5.0")) {  
      $visitor_os ="Windows 2000";  
    } elseif(strpos($user_OSagent,"4.9")) {  
      $visitor_os ="Windows ME";  
    } elseif(strpos($user_OSagent,"NT 4")) {  
      $visitor_os ="Windows NT 4.0";  
    } elseif(strpos($user_OSagent,"98")) {  
      $visitor_os ="Windows 98";  
  } elseif(strpos($user_OSagent,"95")) {  
        $visitor_os ="Windows 95";  
    }elseif(strpos($user_OSagent,"NT")) {  
        $visitor_os ="Windows 较高版本";  
    }elseif(strpos($user_OSagent,"Mac")) {  
        $visitor_os ="Mac";  
    } elseif(strpos($user_OSagent,"Linux")) {  
        $visitor_os ="Linux";  
    } elseif(strpos($user_OSagent,"Unix")) {  
        $visitor_os ="Unix";  
    } elseif(strpos($user_OSagent,"FreeBSD")) {  
        $visitor_os ="FreeBSD";  
    } elseif(strpos($user_OSagent,"SunOS")) {  
        $visitor_os ="SunOS";  
    } elseif(strpos($user_OSagent,"BeOS")) {  
        $visitor_os ="BeOS";  
    } elseif(strpos($user_OSagent,"OS/2")) {  
        $visitor_os ="OS/2";  
    } elseif(strpos($user_OSagent,"PC")) {  
        $visitor_os ="Macintosh";  
    } elseif(strpos($user_OSagent,"AIX")) {  
        $visitor_os ="AIX";  
    } elseif(strpos($user_OSagent,"IBM OS/2")) {  
        $visitor_os ="IBM OS/2";  
    } elseif(strpos($user_OSagent,"BSD")) {  
        $visitor_os ="BSD";  
  } elseif(strpos($user_OSagent,"NetBSD")) {  
        $visitor_os ="NetBSD";  
    } else {  
      $visitor_os ="其它操作系统";  
    }  
    return $visitor_os;  
}
?>
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云博客-资源宝

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值