當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。