Heim > Backend-Entwicklung > PHP-Tutorial > 怎么获取手机型号

怎么获取手机型号

WBOY
Freigeben: 2016-06-13 12:19:58
Original
1914 Leute haben es durchsucht

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

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

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

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage