PHP 擷取用戶端作業系統版本和瀏覽器版本

來源:互聯網
上載者:User
//作業系統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; } //瀏覽器設定 function userBrowser(){$user_OSagent = $_SERVER['HTTP_USER_AGENT']; var_dump($user_OSagent);if(strpos($user_OSagent,"Maxthon") && strpos($user_OSagent,"MSIE")) { $visitor_browser ="Maxthon(Microsoft IE)"; }elseif(strpos($user_OSagent,"Maxthon 2.0")) { $visitor_browser ="Maxthon 2.0"; }elseif(strpos($user_OSagent,"Maxthon")) { $visitor_browser ="Maxthon"; }elseif(strpos($user_OSagent,"MSIE 9.0")) { $visitor_browser ="MSIE 9.0"; }elseif(strpos($user_OSagent,"MSIE 8.0")) { $visitor_browser ="MSIE 8.0"; }elseif(strpos($user_OSagent,"MSIE 7.0")) { $visitor_browser ="MSIE 7.0"; }elseif(strpos($user_OSagent,"MSIE 6.0")) { $visitor_browser ="MSIE 6.0"; } elseif(strpos($user_OSagent,"MSIE 5.5")) { $visitor_browser ="MSIE 5.5"; } elseif(strpos($user_OSagent,"MSIE 5.0")) { $visitor_browser ="MSIE 5.0"; } elseif(strpos($user_OSagent,"MSIE 4.01")) { $visitor_browser ="MSIE 4.01"; }elseif(strpos($user_OSagent,"MSIE")) { $visitor_browser ="MSIE 較高版本"; }elseif(strpos($user_OSagent,"NetCaptor")) { $visitor_browser ="NetCaptor"; } elseif(strpos($user_OSagent,"Netscape")) { $visitor_browser ="Netscape"; }elseif(strpos($user_OSagent,"Chrome")) { $visitor_browser ="Chrome"; } elseif(strpos($user_OSagent,"Lynx")) { $visitor_browser ="Lynx"; } elseif(strpos($user_OSagent,"Opera")) { $visitor_browser ="Opera"; } elseif(strpos($user_OSagent,"Konqueror")) { $visitor_browser ="Konqueror"; } elseif(strpos($user_OSagent,"Mozilla/5.0")) { $visitor_browser ="Mozilla"; } elseif(strpos($user_OSagent,"Firefox")) { $visitor_browser ="Firefox"; }elseif(strpos($user_OSagent,"U")) { $visitor_browser ="Firefox"; } else { $visitor_browser ="其它"; } return $visitor_browser; }$out_ieos =userBrowser(); $out_system = userOS();var_dump($out_ieos,$out_system);
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.