当前位置: 首页>>代码示例>>PHP>>正文


PHP DeviceModels::identify方法代码示例

本文整理汇总了PHP中DeviceModels::identify方法的典型用法代码示例。如果您正苦于以下问题:PHP DeviceModels::identify方法的具体用法?PHP DeviceModels::identify怎么用?PHP DeviceModels::identify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DeviceModels的用法示例。


在下文中一共展示了DeviceModels::identify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: analyseUserAgent


//.........这里部分代码省略.........
     } else {
         if (preg_match('/\\(Ubuntu; (Mobile|Tablet)/u', $ua)) {
             $this->os->name = 'Ubuntu Touch';
             if (preg_match('/\\(Ubuntu; Mobile/u', $ua)) {
                 $this->device->type = TYPE_MOBILE;
             }
             if (preg_match('/\\(Ubuntu; Tablet/u', $ua)) {
                 $this->device->type = TYPE_TABLET;
             }
         } else {
             if (preg_match('/\\(Ubuntu ([0-9.]+) like Android/u', $ua, $match)) {
                 $this->os->name = 'Ubuntu Touch';
                 $this->os->version = new Version(array('value' => $match[1]));
                 $this->device->type = TYPE_MOBILE;
             }
         }
     }
     /****************************************************
      *		iOS
      */
     if (preg_match('/iPhone/u', $ua) && !preg_match('/like iPhone/u', $ua) || preg_match('/iPad/u', $ua) || preg_match('/iPod/u', $ua)) {
         $this->os->name = 'iOS';
         $this->os->version = new Version(array('value' => '1.0'));
         if (preg_match('/OS (.*) like Mac OS X/u', $ua, $match)) {
             $this->os->version = new Version(array('value' => str_replace('_', '.', $match[1])));
             if ($this->os->version->is('<', '4')) {
                 $this->os->alias = 'iPhone OS';
             }
         }
         if (preg_match('/iPhone Simulator;/u', $ua)) {
             $this->device->type = TYPE_EMULATOR;
         } else {
             if (preg_match('/(iPad|iPhone( 3GS| 3G| 4S| 4| 5)?|iPod( touch)?)/u', $ua, $match)) {
                 $device = DeviceModels::identify('ios', $match[0]);
                 if ($device) {
                     $this->device = $device;
                 }
             }
             if (preg_match('/(iPad|iPhone|iPod)[0-9],[0-9]/u', $ua, $match)) {
                 $device = DeviceModels::identify('ios', $match[0]);
                 if ($device) {
                     $this->device = $device;
                 }
             }
         }
     } else {
         if (preg_match('/Mac OS X/u', $ua)) {
             $this->os->name = 'OS X';
             if (preg_match('/Mac OS X (10[0-9\\._]*)/u', $ua, $match)) {
                 $this->os->version = new Version(array('value' => str_replace('_', '.', $match[1]), 'details' => 2));
                 if ($this->os->version->is('<', '10.7')) {
                     $this->os->alias = 'Mac OS X';
                 }
                 if ($this->os->version->is('10.7')) {
                     $this->os->version->nickname = 'Lion';
                 }
                 if ($this->os->version->is('10.8')) {
                     $this->os->version->nickname = 'Mountain Lion';
                 }
                 if ($this->os->version->is('10.9')) {
                     $this->os->version->nickname = 'Mavericks';
                 }
                 if ($this->os->version->is('10.10')) {
                     $this->os->version->nickname = 'Yosemite';
                 }
                 if ($this->os->version->is('10.11')) {
开发者ID:nimble,项目名称:WhichBrowser,代码行数:67,代码来源:whichbrowser.php

示例2: analyseUserAgent


//.........这里部分代码省略.........
             $this->device->type = TYPE_DESKTOP;
         }
         if (preg_match('/Ubuntu/', $ua)) {
             $this->os->name = 'Ubuntu';
             if (preg_match('/Ubuntu\\/([0-9.]*)/', $ua, $match)) {
                 $this->os->version = new Version(array('value' => $match[1]));
             }
             $this->device->type = TYPE_DESKTOP;
         }
     } else {
         if (preg_match('/\\(Ubuntu; (Mobile|Tablet)/', $ua)) {
             $this->os->name = 'Ubuntu Touch';
             if (preg_match('/\\(Ubuntu; Mobile/', $ua)) {
                 $this->device->type = TYPE_MOBILE;
             }
             if (preg_match('/\\(Ubuntu; Tablet/', $ua)) {
                 $this->device->type = TYPE_TABLET;
             }
         }
     }
     /****************************************************
      *		iOS
      */
     if (preg_match('/iPhone/', $ua) || preg_match('/iPad/', $ua) || preg_match('/iPod/', $ua)) {
         $this->os->name = 'iOS';
         $this->os->version = new Version(array('value' => '1.0'));
         if (preg_match('/OS (.*) like Mac OS X/', $ua, $match)) {
             $this->os->version = new Version(array('value' => str_replace('_', '.', $match[1])));
         }
         if (preg_match('/iPhone Simulator;/', $ua)) {
             $this->device->type = TYPE_EMULATOR;
         } else {
             if (preg_match('/(iPad|iPhone( 3GS| 3G| 4S| 4| 5)?|iPod( touch)?)/', $ua, $match)) {
                 $device = DeviceModels::identify('ios', $match[0]);
                 if ($device) {
                     $this->device = $device;
                 }
             }
             if (preg_match('/(iPad|iPhone|iPod)[0-9],[0-9]/', $ua, $match)) {
                 $device = DeviceModels::identify('ios', $match[0]);
                 if ($device) {
                     $this->device = $device;
                 }
             }
         }
     } else {
         if (preg_match('/Mac OS X/', $ua)) {
             $this->os->name = 'Mac OS X';
             if (preg_match('/Mac OS X (10[0-9\\._]*)/', $ua, $match)) {
                 $this->os->version = new Version(array('value' => str_replace('_', '.', $match[1])));
             }
             $this->device->type = TYPE_DESKTOP;
         }
     }
     /****************************************************
      *		Windows
      */
     if (preg_match('/Windows/', $ua)) {
         $this->os->name = 'Windows';
         $this->device->type = TYPE_DESKTOP;
         if (preg_match('/Windows NT ([0-9]\\.[0-9])/', $ua, $match)) {
             $this->os->version = new Version(array('value' => $match[1]));
             switch ($match[1]) {
                 case '6.3':
                     if (preg_match('/; ARM;/', $ua)) {
                         $this->os->version = new Version(array('value' => $match[1], 'alias' => 'RT 8.1'));
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:67,代码来源:whichbrowser.php


注:本文中的DeviceModels::identify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。