欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Js vs php 判断系统

程序员文章站 2022-04-21 10:20:22
JSfunction IOSVersion() {var ua = navigator.userAgent.toLowerCase()var phoneReg = /(iphone|ipod|((?:android)?.?mobile)|j2me|mobi|blackberry|nokia|maemo|mini)/iif (phoneReg.test(ua)) {var ver = ua.match(/ os (.?) like mac os/)if (ver) {return ver[1]....

JS

function IOSVersion() {
    var ua = navigator.userAgent.toLowerCase()
    var phoneReg = /(iphone|ipod|((?:android)?.*?mobile)|j2me|mobi|blackberry|nokia|maemo|mini)/i
    if (phoneReg.test(ua)) {
      var ver = ua.match(/ os (.*?) like mac os/)
      if (ver) {
        return ver[1].replace(/_/g, '.')
      }
    }
    return false
}

function isAndroid() {
  var ua = navigator.userAgent.toLowerCase()
  var phoneReg = /android/i
  if (phoneReg.test(ua)) {
    return true
  }
  return false
}

php

function get_device_type()
{
//全部变成小写字母
    $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
    $type = 'other';
//分别进行判断
    if (strpos($agent, 'iphone') || strpos($agent, 'ipad')) {
        $type = 'ios';
    }
    if (strpos($agent, 'android')) {
        $type = 'android';
    }
    return $type;
}

本文地址:https://blog.csdn.net/weixin_41865469/article/details/108732096

相关标签: js php