在我的開發機器中,我將error_reporting設置爲E_ALL | E_STRICT
,以查看我的代碼中發生的所有錯誤消息。 但是,當我處理捕獲的異常,如:異常消息和開發者在開發時發送了錯誤
try {
throw new MyException('Exception message.');
} catch (MyException $e) {
// code that handles the exception but without print anything
}
PHP始終顯示錯誤消息:
MyException: Exception message in file://path/to/failed/file.php
和PHP後不能發送新的報頭。
你知道一些方法來避免自動生成的PHP錯誤,通過提出但捕獲異常與display_errors=On
和error_reporting=E_ALL |E_STRICT
?
我不打印消息,是打印消息的PHP錯誤處理程序。我想避免這種情況。 –
從你的問題:'echo $ e-> getMessages();'。我誤解了什麼嗎? – middus
對不起,我添加了回聲。 –