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


PHP request::accept_types方法代码示例

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


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

示例1: reset

 public static function reset()
 {
     request::$accept_charsets = NULL;
     request::$accept_encodings = NULL;
     request::$accept_languages = NULL;
     request::$accept_types = NULL;
     request::$user_agent = NULL;
 }
开发者ID:swk,项目名称:bluebox,代码行数:8,代码来源:Helper_Request_Test.php

示例2: parse_accept_header

 /**
  * Parses client's HTTP Accept request header, and builds array structure representing it.
  *
  * @return  void
  */
 protected static function parse_accept_header()
 {
     // Run this function just once
     if (request::$accept_types !== NULL) {
         return;
     }
     // Initialize accept_types array
     request::$accept_types = array();
     // No HTTP Accept header found
     if (empty($_SERVER['HTTP_ACCEPT'])) {
         // Accept everything
         request::$accept_types['*']['*'] = 1;
         return;
     }
     // Remove linebreaks and parse the HTTP Accept header
     foreach (explode(',', str_replace(array("\r", "\n"), '', $_SERVER['HTTP_ACCEPT'])) as $accept_entry) {
         // Explode each entry in content type and possible quality factor
         $accept_entry = explode(';', trim($accept_entry), 2);
         // Explode each content type (e.g. "text/html")
         $type = explode('/', $accept_entry[0], 2);
         // Skip invalid content types
         if (!isset($type[1])) {
             continue;
         }
         // Assume a default quality factor of 1 if no custom q value found
         $q = (isset($accept_entry[1]) and preg_match('~\\bq\\s*+=\\s*+([.0-9]+)~', $accept_entry[1], $match)) ? (double) $match[1] : 1;
         // Populate accept_types array
         if (!isset(request::$accept_types[$type[0]][$type[1]]) or $q > request::$accept_types[$type[0]][$type[1]]) {
             request::$accept_types[$type[0]][$type[1]] = $q;
         }
     }
 }
开发者ID:BGCX261,项目名称:zr4u-svn-to-git,代码行数:37,代码来源:request.php

示例3: parse_accept_content_header

 /**
  * Parses a client's HTTP Accept header
  */
 protected static function parse_accept_content_header()
 {
     // Run this function just once
     if (request::$accept_types !== NULL) {
         return;
     }
     // No HTTP Accept header found
     if (empty($_SERVER['HTTP_ACCEPT'])) {
         // Accept everything
         request::$accept_types['*']['*'] = 1;
     } else {
         request::$accept_types = array();
         foreach (request::parse_accept_header($_SERVER['HTTP_ACCEPT']) as $type => $q) {
             // Explode each content type (e.g. "text/html")
             $type = explode('/', $type, 2);
             // Skip invalid content types
             if (!isset($type[1])) {
                 continue;
             }
             request::$accept_types[$type[0]][$type[1]] = $q;
         }
     }
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:26,代码来源:request.php


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