當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserAgentMatcher::startsWith方法代碼示例

本文整理匯總了PHP中UserAgentMatcher::startsWith方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserAgentMatcher::startsWith方法的具體用法?PHP UserAgentMatcher::startsWith怎麽用?PHP UserAgentMatcher::startsWith使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserAgentMatcher的用法示例。


在下文中一共展示了UserAgentMatcher::startsWith方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createUserAgentMatcher

 /**
  * Determines which UserAgentMatcher is the best fit for the incoming user agent and returns it
  * @param TeraWurfl $wurfl
  * @param String $userAgent
  * @return UserAgentMatcher
  */
 public static function createUserAgentMatcher(TeraWurfl $wurfl, $userAgent)
 {
     // $isMobile means it IS MOBILE, $isDesktop means it IS DESKTOP
     // $isMobile does NOT mean it IS DESKTOP and vica-versa
     $isMobile = UserAgentUtils::isMobileBrowser($userAgent);
     $isDesktop = UserAgentUtils::isDesktopBrowser($userAgent);
     $userAgent_lcase = strtolower($userAgent);
     // Process exceptions
     if (TeraWurflConfig::$SIMPLE_DESKTOP_ENGINE_ENABLE && $userAgent == WurflConstants::$SIMPLE_DESKTOP_UA) {
         // SimpleDesktopUserAgentMatcher is included via require_once realpath(dirname(__FILE__).'/in TeraWurfl.php
         return new SimpleDesktopUserAgentMatcher($wurfl);
     }
     // Process MOBILE user agents
     if (!$isDesktop) {
         // High workload UAMs go first
         // Nokia
         if (UserAgentMatcher::contains($userAgent_lcase, 'nokia')) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/NokiaUserAgentMatcher.php');
             return new NokiaUserAgentMatcher($wurfl);
         }
         // Samsung
         if (UserAgentMatcher::contains($userAgent, array("Samsung/SGH", "SAMSUNG-SGH")) || UserAgentMatcher::startsWith($userAgent, array("SEC-", "Samsung", "SAMSUNG", "SPH", "SGH", "SCH")) || stripos($userAgent, 'samsung') !== false) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/SamsungUserAgentMatcher.php');
             return new SamsungUserAgentMatcher($wurfl);
         }
         // Blackberry
         if (stripos($userAgent, "blackberry") !== false) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/BlackBerryUserAgentMatcher.php');
             return new BlackBerryUserAgentMatcher($wurfl);
         }
         // SonyEricsson
         if (UserAgentMatcher::contains($userAgent, 'Sony')) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/SonyEricssonUserAgentMatcher.php');
             return new SonyEricssonUserAgentMatcher($wurfl);
         }
         // Motorola
         if (UserAgentMatcher::startsWith($userAgent, array('Mot-', 'MOT-', 'MOTO', 'moto')) || UserAgentMatcher::contains($userAgent, 'Motorola')) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/MotorolaUserAgentMatcher.php');
             return new MotorolaUserAgentMatcher($wurfl);
         }
         // Continue processing UAMs in alphabetical order
         // Alcatel
         if (UserAgentMatcher::startsWith($userAgent_lcase, "alcatel")) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/AlcatelUserAgentMatcher.php');
             return new AlcatelUserAgentMatcher($wurfl);
         }
         // Apple
         if (UserAgentMatcher::contains($userAgent, array("iPhone", "iPod", "iPad", "(iphone"))) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/AppleUserAgentMatcher.php');
             return new AppleUserAgentMatcher($wurfl);
         }
         // BenQ
         if (UserAgentMatcher::startsWith($userAgent_lcase, "benq")) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/BenQUserAgentMatcher.php');
             return new BenQUserAgentMatcher($wurfl);
         }
         // DoCoMo
         if (UserAgentMatcher::startsWith($userAgent, "DoCoMo")) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/DoCoMoUserAgentMatcher.php');
             return new DoCoMoUserAgentMatcher($wurfl);
         }
         // Grundig
         if (UserAgentMatcher::startsWith($userAgent_lcase, "grundig")) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/GrundigUserAgentMatcher.php');
             return new GrundigUserAgentMatcher($wurfl);
         }
         // HTC
         if (UserAgentMatcher::contains($userAgent, array("HTC", "XV6875"))) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/HTCUserAgentMatcher.php');
             return new HTCUserAgentMatcher($wurfl);
         }
         // KDDI
         if (UserAgentMatcher::contains($userAgent, "KDDI-")) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/KddiUserAgentMatcher.php');
             return new KddiUserAgentMatcher($wurfl);
         }
         // Kyocera
         if (UserAgentMatcher::startsWith($userAgent, array("kyocera", "QC-", "KWC-"))) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/KyoceraUserAgentMatcher.php');
             return new KyoceraUserAgentMatcher($wurfl);
         }
         // LG
         if (UserAgentMatcher::startsWith($userAgent_lcase, "lg")) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/LGUserAgentMatcher.php');
             return new LGUserAgentMatcher($wurfl);
         }
         // Mitsubishi
         if (UserAgentMatcher::startsWith($userAgent, "Mitsu")) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/MitsubishiUserAgentMatcher.php');
             return new MitsubishiUserAgentMatcher($wurfl);
         }
         // NEC
         if (UserAgentMatcher::startsWith($userAgent, array("NEC-", "KGT"))) {
             require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/NecUserAgentMatcher.php');
//.........這裏部分代碼省略.........
開發者ID:anubhaBhargava,項目名稱:OpenRecommender,代碼行數:101,代碼來源:UserAgentFactory.php


注:本文中的UserAgentMatcher::startsWith方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。