zoukankan      html  css  js  c++  java
  • PHP获取用户操作系统信息

     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 }
  • 相关阅读:
    电源锁
    Android的三种网络联接方式
    用tcpdump在手机上抓包
    图片出现波纹的问题
    Android 3.1以后 广播接收器的新机制
    OpenGL坐标
    用Messager进行IPC
    PHP 介绍
    View坐标,MotionEvent坐标, 二者的转换,可视区域
    OpenGL ES
  • 原文地址:https://www.cnblogs.com/liusir/p/3166445.html
Copyright © 2011-2022 走看看