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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 輸出類 輸出類是個核心類,它的功能只有一個:發送 Web 頁面內容到請求的瀏覽器。 如果你開啟緩存,它也負責?[緩存](http://codeigniter.org.cn/user_guide/general/caching.html)?你的 Web 頁面。 注解 這個類由系統自動加載,你無需手工加載。 在一般情況下,你可能根本就不會注意到輸出類,因為它無需你的干涉, 對你來說完全是透明的。例如,當你使用?[加載器](http://codeigniter.org.cn/user_guide/libraries/loader.html)?加載一個視圖文件時,它會自動傳入到輸出類,并在系統執行的最后由 CodeIgniter 自動調用。盡管如此,在你需要時,你還是可以對輸出進行手工處理。 * [類參考](http://codeigniter.org.cn/user_guide/libraries/output.html#id2) ## [類參考](http://codeigniter.org.cn/user_guide/libraries/output.html#id4) classCI_Output $parse_exec_vars = TRUE; 啟用或禁用解析偽變量({elapsed_time} 和 {memory_usage})。 CodeIgniter 默認會在輸出類中解析這些變量。要禁用它,可以在你的控制器中設置 這個屬性為 FALSE 。 ~~~ $this->output->parse_exec_vars = FALSE; ~~~ set_output($output) 參數: * **$output**?(string) -- String to set the output to 返回: CI_Output instance (method chaining) 返回類型: CI_Output 允許你手工設置最終的輸出字符串。使用示例: ~~~ $this->output->set_output($data); ~~~ 重要 如果你手工設置輸出,這必須放在方法的最后一步。例如, 如果你正在某個控制器的方法中構造頁面,將 set_output 這句代碼放在方法的最后。 set_content_type($mime_type[,?$charset = NULL]) 參數: * **$mime_type**?(string) -- MIME Type idenitifer string * **$charset**?(string) -- Character set 返回: CI_Output instance (method chaining) 返回類型: CI_Output 允許你設置你的頁面的 MIME 類型,可以很方便的提供 JSON 數據、JPEG、XML 等等格式。 ~~~ $this->output ->set_content_type('application/json') ->set_output(json_encode(array('foo' => 'bar'))); $this->output ->set_content_type('jpeg') // You could also use ".jpeg" which will have the full stop removed before looking in config/mimes.php ->set_output(file_get_contents('files/something.jpg')); ~~~ 重要 確保你傳入到這個方法的 MIME 類型在?application/config/mimes.php?文件中能找到,要不然方法不起任何作用。 你也可以通過第二個參數設置文檔的字符集。 > $this->output->set_content_type('css', 'utf-8'); get_content_type() 返回: Content-Type string 返回類型: string 獲取當前正在使用的 HTTP 頭 Content-Type ,不包含字符集部分。 ~~~ $mime = $this->output->get_content_type(); ~~~ 注解 如果 Content-Type 沒有設置,默認返回 'text/html' 。 get_header($header) 參數: * **$header**?(string) -- HTTP header name 返回: HTTP response header or NULL if not found 返回類型: mixed 返回請求的 HTTP 頭,如果 HTTP 頭還沒設置,返回 NULL 。 例如: ~~~ $this->output->set_content_type('text/plain', 'UTF-8'); echo $this->output->get_header('content-type'); // Outputs: text/plain; charset=utf-8 ~~~ 注解 HTTP 頭名稱是不區分大小寫的。 注解 返回結果中也包括通過 PHP 原生的?header()?函數發送的原始 HTTP 頭。 get_output() 返回: Output string 返回類型: string 允許你手工獲取存儲在輸出類中的待發送的內容。使用示例: ~~~ $string = $this->output->get_output(); ~~~ 注意,只有通過 CodeIgniter 輸出類的某個方法設置過的數據,例如?$this->load->view()?方法,才可以使用該方法獲取到。 append_output($output) 參數: * **$output**?(string) -- Additional output data to append 返回: CI_Output instance (method chaining) 返回類型: CI_Output 向輸出字符串附加數據。 ~~~ $this->output->append_output($data); ~~~ set_header($header[,?$replace = TRUE]) 參數: * **$header**?(string) -- HTTP response header * **$replace**?(bool) -- Whether to replace the old header value, if it is already set 返回: CI_Output instance (method chaining) 返回類型: CI_Output 允許你手工設置服務器的 HTTP 頭,輸出類將在最終顯示頁面時發送它。例如: ~~~ $this->output->set_header('HTTP/1.0 200 OK'); $this->output->set_header('HTTP/1.1 200 OK'); $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT'); $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate'); $this->output->set_header('Cache-Control: post-check=0, pre-check=0'); $this->output->set_header('Pragma: no-cache'); ~~~ set_status_header([$code = 200[,?$text = '']]) 參數: * **$code**?(int) -- HTTP status code * **$text**?(string) -- Optional message 返回: CI_Output instance (method chaining) 返回類型: CI_Output 允許你手工設置服務器的 HTTP 狀態碼。例如: ~~~ $this->output->set_status_header('401'); // Sets the header as: Unauthorized ~~~ [閱讀這里](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)?得到一份完整的 HTTP 狀態碼列表。 注解 這個方法是?[通用方法](http://codeigniter.org.cn/user_guide/general/common_functions.html)?中的?set_status_header()?的別名。 enable_profiler([$val = TRUE]) 參數: * **$val**?(bool) -- Whether to enable or disable the Profiler 返回: CI_Output instance (method chaining) 返回類型: CI_Output 允許你啟用或禁用?[程序分析器](http://codeigniter.org.cn/user_guide/general/profiling.html)?,它可以在你的頁面底部顯示 基準測試的結果或其他一些數據幫助你調試和優化程序。 要啟用分析器,將下面這行代碼放到你的?[控制器](http://codeigniter.org.cn/user_guide/general/controllers.html)?方法的任何位置: ~~~ $this->output->enable_profiler(TRUE); ~~~ 當啟用它時,將生成一份報告并插入到你的頁面的最底部。 要禁用分析器,你可以這樣: ~~~ $this->output->enable_profiler(FALSE); ~~~ set_profiler_sections($sections) 參數: * **$sections**?(array) -- Profiler sections 返回: CI_Output instance (method chaining) 返回類型: CI_Output 當程序分析器啟用時,該方法允許你啟用或禁用程序分析器的特定字段。 請參考?[程序分析器](http://codeigniter.org.cn/user_guide/general/profiling.html)?文檔獲取詳細信息。 cache($time) 參數: * **$time**?(int) -- Cache expiration time in seconds 返回: CI_Output instance (method chaining) 返回類型: CI_Output 將當前頁面緩存一段時間。 更多信息,請閱讀?[文檔緩存](http://codeigniter.org.cn/user_guide/general/caching.html)?。 _display([$output = '']) 參數: * **$output**?(string) -- Output data override 返回: void 返回類型: void 發送最終輸出結果以及服務器的 HTTP 頭到瀏覽器,同時它也會停止基準測試的計時器。 注解 這個方法會在腳本執行的最后自動被調用,你無需手工調用它。 除非你在你的代碼中使用了?exit()?或?die()?結束了腳本執行。 例如: ~~~ $response = array('status' => 'OK'); $this->output ->set_status_header(200) ->set_content_type('application/json', 'utf-8') ->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) ->_display(); exit; ~~~ 注解 手工調用該方法而不結束腳本的執行,會導致重復輸出結果。
                  <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>

                              哎呀哎呀视频在线观看