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

更新时间:2018-10-18    来源:php常用代码    手机版     字体:

【www.bbyears.com--php常用代码】

使用方法

 代码如下

    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


   
       
       
            Basic detection methods
       
       
            isMobile()isMobile(); if($check): ?>class="true">
       
       
            isTablet()isTablet(); if($check): ?>class="true">
       
       
       
       
            Custom detection methods
       
        getRules() as $name => $regex):
                        $check = $detect->{"is".$name}();
        ?>
           
                    is()
                    class="true">
           
       
       
       
           
                Experimental version() method
           
                        foreach($detect->getProperties() as $name => $match):
                $check = $detect->version($name);
                if($check!==false):
            ?>
           
                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

本文来源:http://www.bbyears.com/jiaocheng/45151.html

热门标签

更多>>

本类排行