Rumah >pembangunan bahagian belakang >tutorial php >获得客户端使用操作系统类型的php代码

获得客户端使用操作系统类型的php代码

WBOY
WBOYasal
2016-07-25 08:46:06781semak imbas
  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


Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn