在PHP中,您如何使它在使用error_reporting()函數時僅顯示錯誤。目前IIS PHP應用程序被設置爲'生產機器'。如果將其更改爲開發機器,即使沒有error_reporting(),它也會打印出所有錯誤。PHP按需錯誤報告
0
A
回答
1
我得到了我想要使用的行爲:
0
爲你做
error_reporting(0);
工作?
1
在您的「生產機器」上,您可以直接在PHP腳本中打開或關閉error_reporting ...。
您也可以在您的服務器上的php.ini文件中找到此設置以設置默認值。
<?php
// Turn off all error reporting
error_reporting(0);
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL^E_NOTICE);
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
// Report all PHP errors
error_reporting(-1);
?>
2
error_reporting
可能由您的應用程序設置並覆蓋php.ini設置。
無論如何,你應該從來沒有把它關掉。
相反,在php.ini更改display_errors
到Off
,或者在你的代碼:
ini_set('display_errors', 0);
相關問題
- 1. PHP報告錯誤
- 2. PHP錯誤報告關閉
- 3. PHP錯誤報告:Wordpress
- 4. PHP郵件錯誤報告
- 5. php報告按鈕
- 6. Elmah報告不需要的404錯誤
- 7. 調整類似於錯誤報告的PHP異常報告
- 8. 從php類報告mysql錯誤報告0
- 9. PHP錯誤與配置報告
- 10. PHP與i'.ini'文件錯誤報告
- 11. PHP腳本沒有錯誤報告
- 12. 在xampp中關閉php錯誤報告?
- 13. php嘗試捕獲錯誤報告
- 14. 向php腳本報告AJAX錯誤
- 15. PHP將不會報告錯誤
- 16. 無法讓PHP錯誤報告工作
- 17. 錯誤報告的php ini設置
- 18. PHP生成報告(JasperReports)TCPDF錯誤:
- 19. PHP和Windows 7的錯誤報告
- 20. php,ajax錯誤報告不起作用
- 21. Fedora 17 apache php顯示錯誤報告
- 22. 在PHP腳本中報告錯誤
- 23. Zend的表現 - PHP錯誤報告
- 24. 關閉php關閉錯誤報告
- 25. 無法讓PHP報告錯誤
- 26. GDK錯誤報告
- 27. Laravel報告錯誤
- 28. XAMPP錯誤報告
- 29. MongoDB錯誤報告
- 30. Python錯誤報告
我已在php.ini中設置使用error_reporting到默認的'E_ALL&〜DEPRECATED'和display_errors設置爲Off。但是當我把error_reporting(-1);在錯誤填充的php文件的頂部,它只是顯示一個空白頁面。 – Ray 2012-07-13 19:33:00
儘管我的日誌文件中包含錯誤,但在開發過程中將它們放在頁面上會更方便。 – Ray 2012-07-13 19:39:11
@Raymond:不確定你想要什麼。你想展示或隱藏它們?你能澄清嗎? – netcoder 2012-07-13 19:48:57