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


PHP Input::server方法代码示例

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


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

示例1: respondWithArray

 protected function respondWithArray(array $array, array $headers = [])
 {
     $mimeTypeRaw = Input::server('HTTP_ACCEPT', '*/*');
     // If its empty or has */* then default to JSON
     if ($mimeTypeRaw === '*/*') {
         $mimeType = 'application/json';
     } else {
         // You'll probably want to do something intelligent with charset if provided
         // This chapter just assumes UTF8 everything everywhere
         $mimeParts = (array) explode(',', $mimeTypeRaw);
         $mimeType = strtolower($mimeParts[0]);
     }
     switch ($mimeType) {
         case 'application/json':
             $contentType = 'application/json';
             $content = json_encode($array);
             break;
         case 'application/x-yaml':
             $contentType = 'application/x-yaml';
             $dumper = new YamlDumper();
             $content = $dumper->dump($array, 2);
             break;
         default:
             $contentType = 'application/json';
             $content = json_encode(['error' => ['code' => static::CODE_INVALID_MIME_TYPE, 'http_code' => 415, 'message' => sprintf('Content of type %s is not supported.', $mimeType)]]);
     }
     $response = Response::make($content, $this->statusCode, $headers);
     $response->header('Content-Type', $contentType);
     return $response;
 }
开发者ID:kife-design,项目名称:knoters,代码行数:30,代码来源:ApiController.php

示例2: map

 /**
  * Define the routes for the application.
  *
  * @param  \Illuminate\Routing\Router $router
  * @return void
  */
 public function map(Router $router)
 {
     #if (!$this->app->routesAreCached()) {
     // Handle legacy routes
     $router->get('blog/wp-content/uploads/{img_ref_path}', function ($img_ref_path) {
         return file_get_contents(img_path($img_ref_path));
     });
     $router->group(['namespace' => $this->namespace], function ($router) {
         if (in_array(Input::server('HTTP_HOST'), ['www.joejiko.com', 'local.joejiko.com'])) {
             require_once __DIR__ . '/../Http/routes.php';
         }
     });
     #}
 }
开发者ID:jjiko,项目名称:blog,代码行数:20,代码来源:RouteServiceProvider.php


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