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
上一篇: HashSet集合