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

作者:matrix

被围观: 1,717 次

发布时间:2015-01-14

分类:兼容并蓄 |

2 条评论 »

💡NOTICE:这是一个创建于 2247 天前的主题,其中的信息可能已经有所发展或是发生改变。

b939c39ef086c11589e563fa42bc88ea.png

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值