## PHP獲取客戶端操作系統信息
```php
/*
* PHP獲取客戶端操作系統信息
*/
function get_os(){
$agent = $_SERVER['HTTP_USER_AGENT'];
$os = false;
if (preg_match('/win/i', $agent) && strpos($agent, '95'))
{
$os = 'Windows 95';
}
else if (preg_match('/win 9x/i', $agent) && strpos($agent, '4.90'))
{
$os = 'Windows ME';
}
else if (preg_match('/win/i', $agent) && preg_match('/98/i', $agent))
{
$os = 'Windows 98';
}
else if (preg_match('/win/i', $agent) && preg_match('/nt 6.0/i', $agent))
{
$os = 'Windows Vista';
}
else if (preg_match('/win/i', $agent) && preg_match('/nt 6.1/i', $agent))
{
$os = 'Windows 7';
}
else if (preg_match('/win/i', $agent) && preg_match('/nt 6.2/i', $agent))
{
$os = 'Windows 8';
}else if(preg_match('/win/i', $agent) && preg_match('/nt 10.0/i', $agent))
{
$os = 'Windows 10';#添加win10判斷
}else if (preg_match('/win/i', $agent) && preg_match('/nt 5.1/i', $agent))
{
$os = 'Windows XP';
}
else if (preg_match('/win/i', $agent) && preg_match('/nt 5/i', $agent))
{
$os = 'Windows 2000';
}
else if (preg_match('/win/i', $agent) && preg_match('/nt/i', $agent))
{
$os = 'Windows NT';
}
else if (preg_match('/win/i', $agent) && preg_match('/32/i', $agent))
{
$os = 'Windows 32';
}
else if (preg_match('/linux/i', $agent))
{
$os = 'Linux';
}
else if (preg_match('/unix/i', $agent))
{
$os = 'Unix';
}
else if (preg_match('/sun/i', $agent) && preg_match('/os/i', $agent))
{
$os = 'SunOS';
}
else if (preg_match('/ibm/i', $agent) && preg_match('/os/i', $agent))
{
$os = 'IBM OS/2';
}
else if (preg_match('/Mac/i', $agent) && preg_match('/PC/i', $agent))
{
$os = 'Macintosh';
}
else if (preg_match('/PowerPC/i', $agent))
{
$os = 'PowerPC';
}
else if (preg_match('/AIX/i', $agent))
{
$os = 'AIX';
}
else if (preg_match('/HPUX/i', $agent))
{
$os = 'HPUX';
}
else if (preg_match('/NetBSD/i', $agent))
{
$os = 'NetBSD';
}
else if (preg_match('/BSD/i', $agent))
{
$os = 'BSD';
}
else if (preg_match('/OSF1/i', $agent))
{
$os = 'OSF1';
}
else if (preg_match('/IRIX/i', $agent))
{
$os = 'IRIX';
}
else if (preg_match('/FreeBSD/i', $agent))
{
$os = 'FreeBSD';
}
else if (preg_match('/teleport/i', $agent))
{
$os = 'teleport';
}
else if (preg_match('/flashget/i', $agent))
{
$os = 'flashget';
}
else if (preg_match('/webzip/i', $agent))
{
$os = 'webzip';
}
else if (preg_match('/offline/i', $agent))
{
$os = 'offline';
}
else
{
$os = '未知操作系統';
// $os = get_device_type();
}
return $os;
}
```
- PHP獲取客戶端瀏覽器信息和版本
- PHP獲取客戶端操作系統信息
- 無限級分類
- git使用
- 權限檢測思路
- Vue學習
- 遇到的一些問題
- PHP的編碼思維和技巧
- mysql復習
- tp5
- ThinkPHP5.x 公共函數
- TP5登錄注冊
- TP5使用模板繼承
- ThinkPHP5.1 清除緩存
- thinkphp5實現安裝程序
- 安全
- tp中實現跨域代碼
- ThinkPHP5.1配合pjax實現菜單欄無刷新跳轉
- 獲取數據庫版本和數據庫大小
- 模型的基本CURD操作
- 商品spu
- 全局異常處理類
- ExceptionHandler
- BaseException
- PHP函數之error_reporting(E_ALL ^ E_NOTICE)詳細說明
- 微信小程序
- wx:for
- tp6
- 分離的一些模塊
- session開啟
- Spring
- 依賴注入
- 數據結構
- 二叉樹
- js獲取地址欄變量
- PHP設計模式
- 面向對象
- PHP1
- PHP性能優化
- Java學習
- static關鍵字
- 多態
- 接口、階乘
- 大佬給的面試題
- 訪問量為5000萬的博客系統設計
- PHP可變參數
- Nginx的配置案例
- 求數組中的最大值,并返回數組索引
- PHP面試方向
- PHP數組工具類ArrUtil
- 字符串工具類StrUtil
- PHP使用curl發送請求
- mysql
- PHP上傳base64圖片處理函數
- webstorm小程序常用配置
- 郵箱正則表達式
- leetcode mysql記錄
- 函數庫