一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

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

时间:2013-10-30 编辑:简简单单 来源:一聚教程网

使用方法

 代码如下 复制代码

    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();

?>
http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

   
   
    Mobile Detect Local Demo
   
  




   

This is a . Your UA is

   





   

Supported methods


   
       
       
           
       
       
           
       
       
           
       
       
       
       
           
       
        foreach($detect->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.111com.net/upload/2013/10/M.rar

热门栏目