我想var_dump一個變量來調試我的數據庫操作。我不想安裝任何調試器,所以我在我的模型中使用了var_dump($ result)。它輸出錯誤。有沒有辦法var_dump一個變量?
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.
怎麼辦?
我想var_dump一個變量來調試我的數據庫操作。我不想安裝任何調試器,所以我在我的模型中使用了var_dump($ result)。它輸出錯誤。有沒有辦法var_dump一個變量?
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.
怎麼辦?
或者你可以使用CI's logging facility:
log_message('debug', var_export($some_variable));
,並檢查您的應用程序的日誌文件夾,通常應用/日誌。你可以在任何地方 - 模型或控制器。
注意 - 檢查application/config/config.php以確保啓用日誌記錄。這不僅僅是一個開關,您可以選擇要記錄的日誌消息級別。例如,設置爲全部開發,但僅針對生產中的錯誤。
您應該將結果返回給控制器 - 然後在控制器內部執行var_dump($ result)。
我注意到有幾次你不能從模型中獲取var_dump()。
我不好,我做了一個頭('Content-type:text/xml; charset = utf-8');在控制器的構造器中。當我var_dump時,我總是收到錯誤「文檔代碼點火器末尾的額外內容」。 – Emerald214