Github项目Mobile-Detect-检测移动设备的php类

作者:matrix 发布时间:2015年1月14日 分类:兼容并蓄

Github项目Mobile-Detect-检测移动设备的php类

Mobile-Detect php类可以检测是否为移动设备,不用你自己写代码判断ua。它使用 User-Agent 中的字符串,并结合 HTTP Header,来检测移动设备环境,比较靠谱。

网盘备份:http://pan.baidu.com/s/1pJBMFe7

Github地址:https://github.com/serbanghita/Mobile-Detect
官网:http://mobiledetect.net/
DEMO:http://demo.mobiledetect.net/

函数示例

// 载入并实例化类
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
// 移动设备 (手机和平板).
if ( $detect->isMobile() )
//平板设备
if( $detect->isTablet() )
// 判断os
if( $detect->isiOS() )
if( $detect->isAndroidOS() )
...
// 其他的
$detect->is('Chrome')
$detect->is('iOS')
$detect->is('UC Browser')
...

说明:更多的函数请查看DEMO处

参考:

http://mobiledetect.net/

http://yusi123.com/2607.html