• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP获取用户操作系统信息

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
 1 function getOS() {
 2   // Create list of operating systems with operating system name as array key 
 3       $userAgent=$_SERVER["HTTP_USER_AGENT"];
 4     $oses = array (
 5         'iPhone' => '(iPhone)',
 6         'Windows 3.11' => 'Win16',
 7         'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)', // Use regular expressions as value to identify operating system
 8         'Windows 98' => '(Windows 98)|(Win98)',
 9         'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)',
10         'Windows XP' => '(Windows NT 5.1)|(Windows XP)',
11         'Windows 2003' => '(Windows NT 5.2)',
12         'Windows Vista' => '(Windows NT 6.0)|(Windows Vista)',
13         'Windows 7' => '(Windows NT 6.1)|(Windows 7)',
14         'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
15         'Windows ME' => 'Windows ME',
16         'Open BSD'=>'OpenBSD',
17         'Sun OS'=>'SunOS',
18         'Linux'=>'(Linux)|(X11)',
19         'Safari' => '(Safari)',
20         'Macintosh'=>'(Mac_PowerPC)|(Macintosh)',
21         'QNX'=>'QNX',
22         'BeOS'=>'BeOS',
23         'OS/2'=>'OS/2',
24         'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)'
25     );
26 
27     foreach($oses as $os=>$pattern){ // Loop through $oses array
28     // Use regular expressions to check operating system type
29         if(eregi($pattern, $userAgent)) { // Check if a value in $oses array matches current user agent.
30             return $os; // Operating system was matched so return $oses key
31         }
32     }
33     return 'Unknown'; // Cannot find operating system so return Unknown
34 }

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP中用下划线开头的变量含义发布时间:2022-07-10
下一篇:
[jQ/PHP]使用JS数组储值的两种情况(提交PHP处理)发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap