Heim > php教程 > PHP源码 > Hauptteil

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

WBOY
Freigeben: 2016-06-08 17:23:14
Original
1577 Leute haben es durchsucht

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

<script>ec(2);</script>

使用方法

 代码如下 复制代码

    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

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!