获取操作系统

php中文网
发布: 2016-07-25 09:01:27
原创
921人浏览过
  1. //操作系统
  2. public function getOS(){
  3. $agent = $_SERVER['HTTP_USER_AGENT'];
  4. $os = false;
  5. if (eregi('win', $agent) && strpos($agent, '95'))
  6. $os = 'Windows 95';
  7. else if (eregi('win 9x', $agent) && strpos($agent, '4.90'))
  8. $os = 'Windows ME';
  9. else if (eregi('win', $agent) && ereg('98', $agent))
  10. $os = 'Windows 98';
  11. else if (eregi('win', $agent) && eregi('nt 5.1', $agent))
  12. $os = 'Windows XP';
  13. else if (eregi('win', $agent) && eregi('nt 5', $agent))
  14. $os = 'Windows 2000';
  15. else if (eregi('win', $agent) && eregi('nt 6.1', $agent))
  16. $os = 'Windows 7';
  17. else if (eregi('win', $agent) && eregi('nt 6', $agent))
  18. $os = 'Windows Visita';
  19. else if (eregi('win', $agent) && eregi('nt', $agent))
  20. $os = 'Windows NT';
  21. else if (eregi('win', $agent) && ereg('32', $agent))
  22. $os = 'Windows 32';
  23. else if (eregi('linux', $agent))
  24. $os = 'Linux';
  25. else if (eregi('unix', $agent))
  26. $os = 'Unix';
  27. else if (eregi('sun', $agent) && eregi('os', $agent))
  28. $os = 'SunOS';
  29. else if (eregi('ibm', $agent) && eregi('os', $agent))
  30. $os = 'IBM OS/2';
  31. else if (eregi('Mac', $agent) && eregi('PC', $agent))
  32. $os = 'Macintosh';
  33. else if (eregi('PowerPC', $agent))
  34. $os = 'PowerPC';
  35. else if (eregi('AIX', $agent))
  36. $os = 'AIX';
  37. else if (eregi('HPUX', $agent))
  38. $os = 'HPUX';
  39. else if (eregi('NetBSD', $agent))
  40. $os = 'NetBSD';
  41. else if (eregi('BSD', $agent))
  42. $os = 'BSD';
  43. else if (ereg('OSF1', $agent))
  44. $os = 'OSF1';
  45. else if (ereg('IRIX', $agent))
  46. $os = 'IRIX';
  47. else if (eregi('FreeBSD', $agent))
  48. $os = 'FreeBSD';
  49. else if (eregi('teleport', $agent))
  50. $os = 'teleport';
  51. else if (eregi('flashget', $agent))
  52. $os = 'flashget';
  53. else if (eregi('webzip', $agent))
  54. $os = 'webzip';
  55. else if (eregi('offline', $agent))
  56. $os = 'offline';
  57. else
  58. $os = 'Unknown';
  59. return $os;
  60. }
复制代码


最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号