我使用zend框架,我已啓用佈局。有時候一些不好的編碼控制器/動作可能會拋出一個錯誤/警告,例如:「警告:在第12行的/path/to/controllers/controllername.php中出現錯誤」。我想知道是否有單點輸出將數據返回給請求者,以便我可以在發送之前檢查發送的內容。這樣我可以使用正則表達式並從發送給請求者的最終結果中刪除php警告。如何在返回給用戶之前處理所有php數據?
2
A
回答
1
而不是嘗試重新解析輸出,您可以關閉記錄錯誤到輸出和/或更改錯誤報告級別。
您可以直接更改php.ini或使用ini_set方法。
error_reporting(0); // Reporting is off
error_reporting(E_ALL); // Reports all
error_reporting(E_ERROR); // Reports only errors
error_reporting(E_ERROR | E_WARNING); // Reports errors and warnings
ini_set("error_reporting", E_ALL); // Reporting is on
ini_set("error_reporting", 0); // Reporting is off
ini_set("display_errors", 0); // Turn off logging to output
ini_set("log_errors", 1); // Turn on logging to file
ini_set("error_log", "errors.log"); // Name of error log
2
當生成一個ZF項目時,它會創建一個errorcontroller,然後將其設置爲在未捕獲任何異常時使用。此控制器還附帶一個視圖,您可以在其中指定發生錯誤時要顯示的內容。
我不確定它是否使用控制器的設置,或者如果框架使用它,如果它存在,但也許在文檔中。 http://framework.zend.com/manual/en/zend.controller.exceptions.html#zend.controller.exceptions.handling
+0
非常感謝真棒的答案。 – Gean
相關問題
- 1. 在Ember.js中返回數據之前處理數據
- 2. 在返回可觀察值之前處理數據
- 3. 燒瓶返回「好」給用戶並處理數據
- 4. 將數據從處理返回給arduino
- 5. PHP OOP如何處理數據庫查詢返回的數據
- 6. 異步XMLHttpRequest send()在所有數據發送之前返回?
- 7. C WINAPI recv()在收到所有數據之前返回0
- 8. 如何在傳遞給'auc'之前處理從'roc_curve'返回的NaN?
- 9. 如何在返回數據之前等待所有承諾解決?
- 10. X Ray Scraper:在處理數據之前處理數據.write
- 11. Spring批處理如何在寫入數據之前處理數據列表
- 12. 在PHP腳本結束之前PHP向用戶返回輸出
- 13. C#調用事件處理函數之前返回的方法
- 14. 在處理sqlconnection之前從函數返回
- 15. 等待所有功能在返回值之前返回
- 16. 與用戶數據處理在PHP
- 17. 有沒有辦法在處理之前接收所有數據包?
- 18. 如何將所有權限返回給MySQL中的root用戶?
- 19. 如何將所有權限返回給MySQL中的root用戶?
- 20. 在處理它們之前更新POST數據的PHP數組
- 21. 如何處理webservice異常返回給客戶端(SocketTimeoutException)?
- 22. .htaccess處理數據庫中的所有URI,但返回404,否則返回404
- 23. Java Servlet在提交數據庫事務之前返回響應給客戶端
- 24. PHP:如何處理SQL返回值?
- 25. 如何處理PHP PDO execute()返回false?
- 26. 處理回覆數據PHP
- 27. 如何處理動態返回php給出的多行的值?
- 28. 如何在處理任何數據之前測試open-uri url
- 29. Blogger原子提要不會返回所有數據。如何處理它?
- 30. OpenId - 如何在登錄前返回用戶所在的網址
更改錯誤報告級別沒有意義,你知道 –