Home  >  Article  >  Backend Development  >  Get the php code that the client uses operating system type

Get the php code that the client uses operating system type

WBOY
WBOYOriginal
2016-07-25 08:46:06705browse
  1. function userOS(){
  2. $user_OSagent = $_SERVER['HTTP_USER_AGENT'];
  3. if(strpos($user_OSagent,"NT 6.1")){
  4. $visitor_os ="Windows 7";
  5. } elseif(strpos($user_OSagent,"NT 5.1")) {
  6. $visitor_os ="Windows XP (SP2)";
  7. } elseif(strpos($user_OSagent,"NT 5.2") && strpos($user_OSagent,"WOW64")){
  8. $visitor_os ="Windows XP 64-bit Edition";
  9. } elseif(strpos($user_OSagent,"NT 5.2")) {
  10. $visitor_os ="Windows 2003";
  11. } elseif(strpos($user_OSagent,"NT 6.0")) {
  12. $visitor_os ="Windows Vista";
  13. } elseif(strpos($user_OSagent,"NT 5.0")) {
  14. $visitor_os ="Windows 2000";
  15. } elseif(strpos($user_OSagent,"4.9")) {
  16. $visitor_os ="Windows ME";
  17. } elseif(strpos($user_OSagent,"NT 4")) {
  18. $visitor_os ="Windows NT 4.0";
  19. } elseif(strpos($user_OSagent,"98")) {
  20. $visitor_os ="Windows 98";
  21. } elseif(strpos($user_OSagent,"95")) {
  22. $visitor_os ="Windows 95";
  23. }elseif(strpos($user_OSagent,"NT")) {
  24. $visitor_os ="Windows 较高版本";
  25. }elseif(strpos($user_OSagent,"Mac")) {
  26. $visitor_os ="Mac";
  27. } elseif(strpos($user_OSagent,"Linux")) {
  28. $visitor_os ="Linux";
  29. } elseif(strpos($user_OSagent,"Unix")) {
  30. $visitor_os ="Unix";
  31. } elseif(strpos($user_OSagent,"FreeBSD")) {
  32. $visitor_os ="FreeBSD";
  33. } elseif(strpos($user_OSagent,"SunOS")) {
  34. $visitor_os ="SunOS";
  35. } elseif(strpos($user_OSagent,"BeOS")) {
  36. $visitor_os ="BeOS";
  37. } elseif(strpos($user_OSagent,"OS/2")) {
  38. $visitor_os ="OS/2";
  39. } elseif(strpos($user_OSagent,"PC")) {
  40. $visitor_os ="Macintosh";
  41. } elseif(strpos($user_OSagent,"AIX")) {
  42. $visitor_os ="AIX";
  43. } elseif(strpos($user_OSagent,"IBM OS/2")) {
  44. $visitor_os ="IBM OS/2";
  45. } elseif(strpos($user_OSagent,"BSD")) {
  46. $visitor_os ="BSD";
  47. } elseif(strpos($user_OSagent,"NetBSD")) {
  48. $visitor_os ="NetBSD";
  49. } else {
  50. $visitor_os ="其它操作系统";
  51. }
  52. return $visitor_os;
  53. }
复制代码

php


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP generated GUID (UUID)Next article:PHP generated GUID (UUID)