首页 > 技术文章 > 移动设备检测类Mobile_Detect.php

clphp 2017-02-14 20:35 原文

移动设备检测类Mobile_Detect.php

 

http://mobiledetect.net/

分类:PHP 时间:2015年11月28日

Mobile_Detect.php是一个轻量级的开源移动设备检测的PHP Class。它使用User-Agent中的字符串,并结合 HTTP Header来检测移动设备环境。Mobile_Detect.php有一个非常完整的移动设备库,可以检测出所用的设备类型(包括操作系统类型,以及手机品牌等都能检测)和浏览器User-Agent的详细信息。

1、引入Mobile_Detect.php

1
require_once 'Mobile_Detect.php';

2、实例化Mobile_Detect类

1
$detect new Mobile_Detect();

3、调用Mobile_Detect类里的方法和属性

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//平板设备
if$detect->isTablet(){
}
//移动设备但非平板
if$detect->isMobile(&& !$detect->isTablet(){
}
//IOS系统
if$detect->isiOS(){
}
//Android系统
if$detect->isAndroidOS(){
}
//WindowsPhone系统
if$detect->isWindowsPhoneOS(){
}

Mobile_Detect官方主页:http://mobiledetect.net/

 

 

标签:PHP编程

推荐阅读