<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                >[danger] 該組件為系統組件,在組件樹中只可命名為 response ,不可修改為其他名稱。 ## 響應 響應組件用來將控制器返回的數據、設置的HTTP報頭發送至客戶端。 | 類 | 調用 | 運行環境 | | --- | --- | --- | | mix\http\Response | app()->response | mix-httpd | | mix\http\compatible\Response | app()->response | Apache/PHP-FPM | | 門面類 | 調用 | | --- | --- | | mix\facades\Response | Response:: | ## 組件配置 App配置文件中,該組件的默認配置如下: [>> 到 GitHub 查看默認配置 <<](https://github.com/mix-php/mix/blob/v1/apps/httpd/config/http_permanent.php#L46) 參數 `defaultFormat` 全部常量明細: - mix\http\Response::FORMAT_HTML - mix\http\Response::FORMAT_JSON - mix\http\Response::FORMAT_JSONP - mix\http\Response::FORMAT_XML ## 設置響應格式 當開發API接口時,通常需要響應 `JSON`、`JSONP`、`XML` 格式,這時可在控制中指定響應格式,代碼如下: ~~~ public function actionIndex() { app()->response->format = \mix\http\Response::FORMAT_JSON; return ['errcode' => 0, 'errmsg' => 'ok']; } ~~~ 也可以在App配置文件中的 `defaultFormat` 字段中定義默認的響應格式: ~~~ // 默認輸出格式 'defaultFormat' => mix\http\Response::FORMAT_JSON, ~~~ ## 重定向 重定向到首頁。 ~~~ Response::redirect('/'); ~~~ ## 設置 `HTTP` 狀態碼 設置響應的HTTP狀態碼為404。 ~~~ app()->response->statusCode = 404; ~~~ ## 設置 `HTTP` 報頭 設置報頭Content-Type為json格式utf8編碼。 ~~~ Response::setHeader('Content-Type', 'application/json;charset=utf-8'); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看