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

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 介紹 Response組件服務用于 http響應的相關處理。 其他產品也可以使用該組件,請登錄 [GITHUB](https://github.com/houdunwang/response) 查看源代碼與說明文檔。 [TOC] ## 狀態碼 #### 設置狀態碼 向客戶端發送HTTP狀態碼 ``` Response::sendHttpStatus(404); ``` ## 404響應 返回404狀態碼并輸出錯誤視圖,config/app.php 配置文件中的 404 配置段中定義錯誤頁面 ``` return Response::_404(); ``` #### 獲取狀態碼 獲取使用 sendHttpStatus 發送的狀態碼 ``` Response::getCode(); ``` ## 生成鏈接 以下方法生成鏈接但不會進行跳轉,所有跳轉方法都可以使用鏈式string()函數返回鏈接字符串。 #### u 生成url 分隔符可以使用 . 或 / 兩種。 ``` echo u('home.index.add'); //或 echo redirect('home.entry.index')->string(); ``` #### 添加url參數 ``` u('home.index.add',['cid'=>1,'uid'=>2]); //生成url為: ?s=home/index/add&cid=1&uid=2 ``` #### 生成鏈接參數與當前$_GET合并 ``` u('home.index.add',['cid'=>1,'uid'=>2],true); //生成url參數除了指定的cid與uid外還有當前$_GET中所有參數 ``` ## 頁面跳轉 #### 請示當前控制器方法 ``` u('add',['cid'=>1,'uid'=>2]); //全成url為: ?s=默認模塊/默認控制器/add ``` #### 路由鏈接 ``` return redirect()->route('hdcms'); ``` #### 控制器鏈接 go、redirect函數是別名函數功能一致,都會進行跳轉處理。 ``` return go('home.entry.index'); //或 return redirect('home.entry.index'); //或 return redirect()->controller('home.entry.index'); ``` #### 回跳鏈接 ``` return redirect('back'); ``` #### 刷新頁面 ``` return redirect('refresh'); ``` ## 異步響應 #### 語法 ``` public function ajax( $data, $type = "JSON" ) type指返回數據類型包括:TEXT XML JSON 默認為JSON ``` #### 示例 ``` $data=['name'=>'后盾網','url'=>'houdunwang.com'] return Response::ajax($data,'xml'); ``` #### ajax函數 組件提供了ajax函數用于發送異步 ``` $data=['name'=>'后盾網','url'=>'houdunwang.com'] return ajax($data); ``` #### 直接返回 可以在路由閉包或控制器中直接返回數組,系統會自動以json數組響應給前臺。 ``` return ['name'=>'后盾網']; ``` ## 普通模板消息 模板消息是直接以一個頁面顯示消息內容,然后跳轉到指定的地址。 #### 模板文件 模板消息的文件在 system/config/view.php 中定義。 #### 函數語法 ``` /** * 消息提示 * $content 消息內容 * $redirect 跳轉方式 1:with(分配錯誤內容) 2:back或為空(返回上一頁) 3:refresh(刷新當前頁) 4:具體跳轉的Url * $type 信息類型 success(成功),error(失敗),warning(警告),info(提示) * @timeout 等待時間單位秒 */ redirect()->show( $content, $redirect = 'back', $type = 'success', $timeout = 2 ) //或使用函數 message( $content, $redirect = 'back', $type = 'success', $timeout = 2 ); ``` 當跳轉方式為 with 時會將提示信息以數組的形式返回到頁面中,不會使用配置文件中指定的模板文件顯示內容。 #### 示例代碼 ``` return redirect()->show('操作成功','back','success'); //或使用函數調用 message('操作成功','back','success'); ``` > 如果是Ajax異步請求時系統會返回 {valid:1,message:'響應信息'}的JSON數據。succes時valid為1 ,error 時valid為0 #### 模板變量 系統會分配與消息有關的變量到模板中,如果對模板進行了重新定義那么這些變量顯示是需要用到的。因為 跳轉方式為 **with** 時不使用模板,所以模板變量對他沒有意義。 ``` 'content' => '提示內容', 'redirect' => '跳轉方式', 'type' => '消息類型', 'timeout' => '顯示時間' ``` ## 確認模板消息 有確定提示的提示頁面,不支持ajax操作,模板文件在配置項 config/app.php 文件中的 confirm 配置段中設置。 #### 函數語法 ``` /** * 有確定提示的提示頁面 * $message 提示文字 * $sUrl 確定按鈕跳轉的url * $eUrl 取消按鈕跳轉的url */ confirm( $message, $sUrl, $eUrl ); ``` #### 示例代碼 ``` return confirm('確定刪除嗎?',u('ok'),u('cancel')); ``` #### 模板變量 ``` $message=>'提示信息', $sUrl=>'確定按鈕跳轉的url', $eUrl=>'取消按鈕跳轉的url' ```
                  <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>

                              哎呀哎呀视频在线观看