php获取手机设备信息
16lz
2021-01-23
//版本public function getOS(){ $ua = $_SERVER['HTTP_USER_AGENT']; if (strpos($ua, 'Android') !== false) { preg_match("/(?<=Android )[\d\.]{1,}/", $ua, $version); return 'Platform:Android OS_Version:'.$version[0]; } elseif (strpos($ua, 'iPhone') !== false) { preg_match("/(?<=CPU iPhone OS )[\d\_]{1,}/", $ua, $version); return 'Platform:iPhone OS_Version:'.str_replace('_', '.', $version[0]); } elseif (strpos($ua, 'iPad') !== false) { preg_match("/(?<=CPU OS )[\d\_]{1,}/", $ua, $version); return 'Platform:iPad OS_Version:'.str_replace('_', '.', $version[0]); } }//型号public function mobile_type(){ $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 = '其他手机'; } return $brand;}
更多相关文章
- Android中为PopupWindow设置半透明背景的方案(兼容华为手机)
- android 华为Mate 10 spinner 点击区域bug
- 华为发布全新IDE:DevCro Studio,Facebook正自研OS系统!去除Google安
- Nexus 6P 外媒评测:华为造出了最好的 Android 手机?
- Android第三课 联调华为手机
- 华为手机Android Studio开发不显示Logcat解决办法
- 华为十年资深架构师推荐最强Android 架构剖析文档
- Ubuntu 10.10 与 华为 C8650 手机搭建 Android 真机开发调试环境
- T-Mobile G3是华为的android