<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 為什么單獨創建一個Response? 跟`為什么要單獨創建一個Request` 一樣。 原因: 可以管理 如: 在 `swoole` 不應該用 `echo`, 因為 `swoole` 是 `cli` 運行,只會輸出在命令行。 `必須` 只有一個地方能 `輸出響應` 就是此篇的功能 確保有 `集中控制權` 是非常重要 ! (后面代碼有 `echo` 都是不規范的, 應該調用 `此篇` 的功能) ## 創建core/Response.php ``` <?php namespace core; class Response { protected $headers = []; // 要發送的請求頭 protected $content = ''; // 要發送的內容 protected $code = 200; // 發送狀態碼 public function sendContent() // 發送內容 { echo $this->content; } public function sendHeaders() // 發送請求頭 { foreach ($this->headers as $key => $header) header($key.': '.$header); } public function send() // 發送 { $this->sendHeaders(); $this->sendContent(); return $this; } public function setContent($content) // 設置內容 { if( is_array($content)) $content = json_encode($content); $this->content = $content; return $this; } public function getContent() // 獲取內容 { return $this->content; } public function getStatusCode() // 獲取狀態碼 { return $this->code; } public function setCode(int $code) // 設置狀態碼 { $this->code = $code; return $this; } } ``` ## 在容器綁定Response類 編輯 `app.php`的`register` 方法 ![](https://img.kancloud.cn/f0/ad/f0ad878555ff9efa213a1c6011f7c17e_606x187.png) ## 編輯index.php ![](https://img.kancloud.cn/56/90/5690de0edbfdf9f0665cdaf48566e739_824x519.png) ![](https://img.kancloud.cn/06/3b/063bb94f40ec4253318fc802cdfef561_612x175.png)
                  <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>

                              哎呀哎呀视频在线观看