当前位置: 首页>>代码示例>>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;未经允许,请勿转载。