ホームページ >バックエンド開発 >PHPチュートリアル >携帯電話のモデルを入手する方法
携帯電話のモデルを入手するにはどうすればよいですか?
ログインしているユーザーの端末モデルを取得したいので、
次の統計を作成します。
Moblie_detect クラスも試しました
が、このクラスの携帯電話モデルは不完全であり、Xiaomi、Huawei などのモデルはありません
特定の携帯電話モデルが見つかりませんでした。自分で探しました。
ついに携帯電話のブランドを取得したい
-----ソリューションアイデア----- --- ---
<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 />