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


PHP ServerBag::has方法代码示例

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


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

示例1: prepareRequestUri

 protected function prepareRequestUri()
 {
     $requestUri = '';
     if ($this->headers->has('X_REWRITE_URL') && false !== stripos(PHP_OS, 'WIN')) {
         // check this first so IIS will catch
         $requestUri = $this->headers->get('X_REWRITE_URL');
     } elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') {
         // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)
         $requestUri = $this->server->get('UNENCODED_URL');
     } elseif ($this->server->has('REQUEST_URI')) {
         $requestUri = $this->server->get('REQUEST_URI');
         // HTTP proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path
         $schemeAndHttpHost = $this->getScheme() . '://' . $this->getHttpHost();
         if (strpos($requestUri, $schemeAndHttpHost) === 0) {
             $requestUri = substr($requestUri, strlen($schemeAndHttpHost));
         }
     } elseif ($this->server->has('ORIG_PATH_INFO')) {
         // IIS 5.0, PHP as CGI
         $requestUri = $this->server->get('ORIG_PATH_INFO');
         if ($this->server->get('QUERY_STRING')) {
             $requestUri .= '?' . $this->server->get('QUERY_STRING');
         }
     }
     return $requestUri;
 }
开发者ID:krisldz,项目名称:Gekosale2,代码行数:25,代码来源:Request.php

示例2: prepareRequestUri

 protected function prepareRequestUri()
 {
     $requestUri = '';
     if ($this->headers->has('X_ORIGINAL_URL') && false !== stripos(PHP_OS, 'WIN')) {
         // IIS with Microsoft Rewrite Module
         $requestUri = $this->headers->get('X_ORIGINAL_URL');
         $this->headers->remove('X_ORIGINAL_URL');
     } elseif ($this->headers->has('X_REWRITE_URL') && false !== stripos(PHP_OS, 'WIN')) {
         // IIS with ISAPI_Rewrite
         $requestUri = $this->headers->get('X_REWRITE_URL');
         $this->headers->remove('X_REWRITE_URL');
     } elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') {
         // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)
         $requestUri = $this->server->get('UNENCODED_URL');
         $this->server->remove('UNENCODED_URL');
         $this->server->remove('IIS_WasUrlRewritten');
     } elseif ($this->server->has('REQUEST_URI')) {
         $requestUri = $this->server->get('REQUEST_URI');
         // HTTP proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path
         $schemeAndHttpHost = $this->getSchemeAndHttpHost();
         if (strpos($requestUri, $schemeAndHttpHost) === 0) {
             $requestUri = substr($requestUri, strlen($schemeAndHttpHost));
         }
     } elseif ($this->server->has('ORIG_PATH_INFO')) {
         // IIS 5.0, PHP as CGI
         $requestUri = $this->server->get('ORIG_PATH_INFO');
         if ('' != $this->server->get('QUERY_STRING')) {
             $requestUri .= '?' . $this->server->get('QUERY_STRING');
         }
         $this->server->remove('ORIG_PATH_INFO');
     }
     // normalize the request URI to ease creating sub-requests from this request
     $this->server->set('REQUEST_URI', $requestUri);
     return $requestUri;
 }
开发者ID:nfabre,项目名称:symfony,代码行数:35,代码来源:Request.php

示例3: parseAcceptLanguage

 /**
  * Parst den ACCEPT-LANGUAGE Header des Browsers
  * und gibt die präferierten Sprachen zurück
  *
  * @return array
  */
 public function parseAcceptLanguage()
 {
     $locales = [];
     if ($this->server->has('HTTP_ACCEPT_LANGUAGE')) {
         $matches = [];
         preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\\s*(;\\s*q\\s*=\\s*(1|0\\.[0-9]+))?/i', $this->server->get('HTTP_ACCEPT_LANGUAGE'), $matches);
         if (!empty($matches[1])) {
             $locales = array_combine($matches[1], $matches[4]);
             // Für Einträge ohne q-Faktor, Wert auf 1 setzen
             foreach ($locales as $locale => $val) {
                 if ($val === '') {
                     $locales[$locale] = 1;
                 }
             }
             // Liste nach Sprachpräferenz sortieren
             arsort($locales, SORT_NUMERIC);
         }
     }
     return $locales;
 }
开发者ID:acp3,项目名称:core,代码行数:26,代码来源:UserAgent.php


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