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


PHP DeviceModels::cleanup方法代码示例

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


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

示例1: identifyList

 static function identifyList($list, $model, $cleanup = true)
 {
     $original = $model;
     if ($cleanup) {
         $model = DeviceModels::cleanup($model);
     }
     $device = (object) array('type' => TYPE_MOBILE, 'identified' => ID_NONE, 'manufacturer' => null, 'model' => $model, 'identifier' => $original, 'generic' => false);
     foreach ($list as $m => $v) {
         $match = false;
         if (substr($m, -1) == "!") {
             $match = preg_match('/^' . substr($m, 0, -1) . '/iu', $model);
         } else {
             $match = strtolower($m) == strtolower($model);
         }
         if ($match) {
             $device->manufacturer = $v[0];
             $device->model = $v[1];
             if (isset($v[2])) {
                 $device->type = $v[2];
             }
             if (isset($v[3])) {
                 $device->flag = $v[3];
             }
             $device->identified = ID_MATCH_UA;
             if ($device->manufacturer == null && $device->model == null) {
                 $device->identified = ID_PATTERN;
             }
             return $device;
         }
     }
     return $device;
 }
开发者ID:nimble,项目名称:WhichBrowser,代码行数:32,代码来源:whichbrowser.php

示例2: identifyList

 static function identifyList($list, $model, $cleanup = true)
 {
     $original = $model;
     if ($cleanup) {
         $model = DeviceModels::cleanup($model);
     }
     $device = (object) array('type' => TYPE_MOBILE, 'identified' => ID_NONE, 'manufacturer' => null, 'model' => $model, 'identifier' => $original, 'generic' => false);
     foreach ($list as $m => $v) {
         $match = null;
         if (DeviceModels::hasMatch($m, $model)) {
             if (substr($m, -2) == "!!") {
                 foreach ($v as $m2 => $v2) {
                     if (DeviceModels::hasMatch($m2, $model)) {
                         $match = $v2;
                         continue;
                     }
                 }
             } else {
                 $match = $v;
             }
         }
         if ($match) {
             $device->manufacturer = $match[0];
             $device->model = $match[1];
             if (isset($match[2])) {
                 $device->type = $match[2];
             }
             if (isset($match[3])) {
                 $device->flag = $match[3];
             }
             $device->identified = ID_MATCH_UA;
             if ($device->manufacturer == null && $device->model == null) {
                 $device->identified = ID_PATTERN;
             }
             return $device;
         }
     }
     return $device;
 }
开发者ID:karthik0001,项目名称:WhichBrowser,代码行数:39,代码来源:parser.php


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