I'd like for PHP to still send it's minor and fatal errors to the error log but not display it to the user. I thought at first I could use error_reporting(0);
to suppress all error messages, period, but that's not really ideal. I know I could also put everything inside a try-catch but that's not really ideal either. Is there anything more automatic for regular errors like there are for fatal errors (e.g. register_shutdown_function()
)?
Speaking of fatal errors, I tried catching them using register_shutdown_function()
as suggested in this SO answer. When I did it this way the fatal error was caught but error_get_last();
is always empty. I also tried making use of debug_backtrace();
to catch the error message. It does contain the info I want about fatal errors but it appears to have the undesired side effect of actually printing that info out to the user, the very situation I am trying to avoid.
Are there any other ways to do what I'm trying to do here and/or ways I can do this (log the error messages to the console but not to the user) using the methods I have described above? Thank you.