## 響應狀態
Every HTTP response has a numeric [status code](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html). The status code identifies the*type*of HTTP response to be returned to the client. The PSR-7 Response object’s default status code is`200`(OK). You can get the PSR-7 Response object’s status code with the`getStatusCode()`method like this.
> 每個HTTP響應都有一個數字 [status code](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)。狀態代碼標識要返回給客戶機的HTTP響應的類型。PSR-7響應對象的默認狀態代碼是`200`(OK)。可以使用`getStatusCode()`方法獲得PSR-7響應對象的狀態代碼,如下所示。
~~~php
$status = $response->getStatusCode();
~~~
Figure 3: Get response status code.
You can copy a PSR-7 Response object and assign a new status code like this:
> 您可以復制一個PSR-7響應對象并分配一個新的狀態碼,如下所示:
~~~php
$newResponse = $response->withStatus(302);
~~~
Figure 4: Create response with new status code.
- 開始
- 安裝
- 升級指南
- Web服務器
- 概念
- 生命周期
- PSR 7
- 中間件
- 依賴容器
- 實例 及通知和警告處理
- Request
- 請求方法
- 請求頭信息
- 請求主體
- 上傳的文件
- 請求幫助
- 路由對象
- Response
- 響應狀態
- 響應標頭
- 響應體
- 返回JSON
- 視圖模板
- 路由
- 創建路由
- 路由回調
- 路由策略
- 路線占位符
- 路由名
- 路由組
- 路由中間件
- 路由表達式緩存
- 容器識別解析
- 封裝中間件
- 路由的中間件
- 錯誤處理中間件
- 方法重寫的中間件
- 輸出緩沖中間件
- 內容長度中間件
- 擴展功能
- 以 / 結尾的路由模式
- 獲取當前路由
- 設置CORS
- 使用POST表單上傳文件
- 第三方組件
- slim-session
- auth
- slim-api-skeleton
- dir