• 技术文章 >php教程 >PHP源码

    PHP Mobile-Detect检查手机移动设备访问网站

    2016-06-08 17:23:14原创981
    这里给大家介绍一个移动设备检查类了,从google找到的mobile-detect类,这个类可以ct判断android、ios、Tablet平板,浏览器,等比较完美完善的判断ipad,iPhone,win8等

    使用方法

    代码如下 复制代码

    include 'Mobile_Detect.php';
    $detect = new Mobile_Detect();


    if ($detect->isMobile()) {
    // Any mobile device.
    }

    if($detect->isTablet()){
    // Any tablet device.
    }
    Check for a specific platform:

    if($detect->isiOS()){
    // Code to run for the Apple's iOS platform.
    }

    if($detect->isAndroidOS()){
    // Code to run for the Google's Android platform.
    }

    官方实例

    代码如下 复制代码


    require_once 'Mobile_Detect.php';
    $detect = new Mobile_Detect;
    $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
    $scriptVersion = $detect->getScriptVersion();

    ?>




    Mobile Detect Local Demo




    This is a . Your UA is





    Supported methods


















    getRules() as $name => $regex):
    $check = $detect->{'is'.$name}();
    ?>










    foreach($detect->getProperties() as $name => $match):
    $check = $detect->version($name);
    if($check!==false):
    ?>
































    Basic detection methods
    isMobile()isMobile(); if($check): ?>class="true">
    isTablet()isTablet(); if($check): ?>class="true">
    Custom detection methods
    is() class="true">
    Experimental version() method
    version()
    Other tests
    isiphone() isiphone()); ?>
    isIphone() isIphone()); ?>
    istablet() istablet()); ?>
    isIOS() isIOS()); ?>
    isWhateverYouWant() isWhateverYouWant()); ?>



    php-mobile-detect文件下载地焉: http://file.111cn.net/upload/2013/10/M.rar

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:nbsp gt lt quot detect
    上一篇:php 汉字正则表达式实例详解 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • 用PHP MySQL进行分页的详细说明(二)• 费了点心思写的Php图像处理类• php入门教程-留言板程序• 强烈建议大家在学习PHP的时候同时学习SVN使用!• 一个对数据库进行操作的程序
    1/1

    PHP中文网