當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。