<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國際加速解決方案。 廣告
                [TOC] ### 組件說明 > Lying的Response是內置組件,用于控制響應用戶操作。 ### 配置選項 | 配置名 | 參數類型 | 可選 | 默認值 | 說明 | | --- | --- | --- | --- | --- | | class | string | 是 | lying\service\Response | 不可更改 | ### 示例配置 Response組件暫時不需要配置,可直接使用 ### 調用方式 ~~~php \Lying::$maker->get('response'); \Lying::$maker->response(); \Lying::$maker->dispatch; ~~~ ### 方法列表 ~~~php /** * 重置狀態 * @return $this */ public function clear(); ~~~ ***** ~~~php /** * 設置要發送的頭 * @param string|array $name header名,如果此參數是一個數組,則會判斷為一個header數組,value無效 * @param string $value header值 * @return $this */ public function setHeader($name, $value = null); ~~~ ***** ~~~php /** * 設置HTTP狀態碼 * @param int $code * @return $this */ public function setStatusCode($code); ~~~ ***** ~~~ /** * 設置要發送的數據 * @param mixed $data 要發送的數據 * @return $this */ public function setContent($data); ~~~ * * * * * ~~~php /** * 發送響應(只有在調用這個方法的時候才是真正的發送) */ public function send(); ~~~ * * * * * ~~~php /** * 發送文件 * @param string $filePath 文件的路徑 * @param string $attachmentName 要保存的文件名,如果沒寫則使用原來的的文件名 * @param string $mime 文件的mime,不寫的話根據文件后綴去判斷,否則就是application/octet-stream * @param bool $inline 文件的輸出類型是否是inline,否則是attachment * @return $this */ public function sendFile($filePath, $attachmentName = null, $mime = null, $inline = false); ~~~ * * * * * ~~~php /** * 發送字符串當做文件內容 * @param string $content 文件內容 * @param string $attachmentName 要保存的文件名 * @param string $mime 文件的mime,不寫的話就是application/octet-stream * @param bool $inline 文件的輸出類型是否是inline,否則是attachment * @return $this */ public function sendContentAsFile($content, $attachmentName, $mime = null, $inline = false); ~~~ * * * * * ~~~php /** * 使用X-Sendfile下載文件 * @param string $filePath 文件路徑 * @param string $attachmentName 要保存的文件名 * @param string $mime 文件的mime,不寫的話根據文件后綴去判斷,否則就是application/octet-stream * @param bool $inline 文件的輸出類型是否是inline,否則是attachment * @param string $xHeader 使用的HTTP頭,默認為nginx的X-Accel-Redirect,apache用X-Sendfile * @return $this */ public function xSendFile($filePath, $attachmentName = null, $mime = null, $inline = false, $xHeader = 'X-Accel-Redirect'); ~~~ * * * * * ~~~php /** * HTTP重定向 * ``` * redirect('get', ['id' => 100]);跳轉到[當前模塊/當前控制器/get] * redirect('admin/post', ['id' => 100]);跳轉到[當前模塊/admin/post] * redirect('lying/index/name', ['id' => 100]);跳轉到[lying/index/name],參見URL生成 * redirect('/admin/post', ['id' => 100]);跳轉到[/admin/post/?id=100] * redirect('https://www.baidu.com') 必須帶協議頭,跳轉到百度 * ``` * @param string $url 重定向的地址 * @param array $params URL參數 * @param bool $normal 是否把參數設置成?a=1&b=2,默認否,優先pathinfo,只對非/開頭的path * @param int $statusCode HTTP狀態碼,默認302,如果ajax請求出錯,可以手動設置200 * @return $this */ public function redirect($url, array $params = [], $normal = false, $statusCode = 302); ~~~ ### 使用示例 ~~~php <?php namespace module\index\controller; use lying\service\Controller; /** * Class IndexCtrl * @package module\index\controller */ class IndexCtrl extends Controller { /** * 首頁 * @return string */ public function index() { //常規的頁面渲染輸出方式 //return $this->render(); //更多的輸出方式 $response = $this->maker->response; //輸出渲染后的頁面 //return $response->setContent($this->render()); //設置輸出的http返回碼 //$response->setStatusCode(200); //立即發送,立即發送后,如果再次調用send,則不會發送,除非調用clear清空所有輸出緩沖 //$response->setContent($this->render())->send(); //輸出文件 //return $response->sendFile('/www/file/a.txt'); //把字符串當做文件輸出 //return $response->sendContentAsFile('文件內容', 'hello.txt'); //調用nginx的sendfile文件下載 //return $response->xSendFile('/www/data/test.mp3'); } } ~~~
                  <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>

                              哎呀哎呀视频在线观看