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


PHP Mobile_Detect::setHttpHeaders方法代碼示例

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


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

示例1: __invoke

 /**
  * Retrieve Mobile-detect service
  *
  * @param \Zend\Http\Headers $oHeaders
  *
  * @throws \LogicException
  * @return \Mobile_Detect
  */
 public function __invoke(\Zend\Http\Headers $oHeaders = null)
 {
     $oController = $this->getController();
     if (!$oController) {
         throw new \LogicException('Controller is undefined for MobileDetect controller plugin');
     }
     if ($oHeaders) {
         $this->mobileDetect->setHttpHeaders($oHeaders->toArray());
         $this->mobileDetect->setUserAgent($oHeaders->get('user-agent')->getFieldValue());
     }
     return $this->mobileDetect;
 }
開發者ID:neilime,項目名稱:zf2-mobile-detect,代碼行數:20,代碼來源:MobileDetectPlugin.php

示例2: testSetHttpHeaders

 /**
  * Headers should be reset when you use setHttpHeaders.
  * @covers Mobile_Detect::setHttpHeaders
  * @issue #144
  */
 public function testSetHttpHeaders()
 {
     $header1 = array('HTTP_PINK_PONY' => 'I secretly love ponies >_>');
     $md = new Mobile_Detect($header1);
     $this->assertSame($md->getHttpHeaders(), $header1);
     $header2 = array('HTTP_FIRE_BREATHING_DRAGON' => 'yeah!');
     $md->setHttpHeaders($header2);
     $this->assertSame($md->getHttpHeaders(), $header2);
 }
開發者ID:kennygrage,項目名稱:dynastyDish,代碼行數:14,代碼來源:BasicsTest.php

示例3: testSetCfHeaders

 /**
  * Read response from cloudfront, if the cloudfront headers are detected
  * @covers Mobile_Detect::setCfHeaders
  */
 public function testSetCfHeaders()
 {
     // Test mobile detected
     $header1 = array('HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_MOBILE_VIEWER' => 'true', 'HTTP_CLOUDFRONT_IS_TABLET_VIEWER' => 'false');
     $md = new Mobile_Detect($header1);
     $this->assertSame($md->getCfHeaders(), $header1);
     $this->assertSame($md->getUserAgent(), 'Amazon CloudFront');
     $this->assertSame($md->isTablet(), false);
     $this->assertSame($md->isMobile(), true);
     // Test neither mobile nor tablet (desktop)
     $header2 = array('HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER' => 'true', 'HTTP_CLOUDFRONT_IS_MOBILE_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_TABLET_VIEWER' => 'false');
     $md->setHttpHeaders($header2);
     $this->assertSame($md->getCfHeaders(), $header2);
     $this->assertSame($md->getUserAgent(), 'Amazon CloudFront');
     $this->assertSame($md->isTablet(), false);
     $this->assertSame($md->isMobile(), false);
     // Test tablet detected
     $header3 = array('HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_MOBILE_VIEWER' => 'false', 'HTTP_CLOUDFRONT_IS_TABLET_VIEWER' => 'true');
     $md->setCfHeaders($header3);
     $this->assertSame($md->getCfHeaders(), $header3);
     $this->assertSame($md->getUserAgent(), 'Amazon CloudFront');
     $this->assertSame($md->isTablet(), true);
     $this->assertSame($md->isMobile(), false);
     // Check if the headers are cleared
     $header4 = array();
     $md->setHttpHeaders($header4);
     $this->assertSame($md->getCfHeaders(), $header4);
 }
開發者ID:a53ali,項目名稱:CakePhP,代碼行數:32,代碼來源:BasicsTest.php

示例4: __invoke

 /**
  * Retrieve Mobile-detect service
  *
  * @param \Zend\Http\Headers $oHeaders
  *
  * @return \Mobile_Detect
  */
 public function __invoke(\Zend\Http\Headers $oHeaders = null)
 {
     if ($oHeaders) {
         $this->mobileDetect->setHttpHeaders($oHeaders->toArray());
         $this->mobileDetect->setUserAgent($oHeaders->get('user-agent')->getFieldValue());
     }
     return $this->mobileDetect;
 }
開發者ID:neilime,項目名稱:zf2-mobile-detect,代碼行數:15,代碼來源:MobileDetectHelper.php


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