سؤال

I'm getting close to taking a PHP application live and so I know that I need to disable error reporting (to hide errors from users) and instead log the errors.

I found the set_error_handler function in the PHP docs and there is an example shown, but I'm wondering if there is any kind of standard error handler function (to be set as the callback in set_error_handler) or class that is typically used by PHP developers to log errors?

If there isn't a function or class that is considered "standard," would you show your error handling function?

هل كانت مفيدة؟

المحلول

Your best bet would be to make changes to the php.ini file to turn on-screen error reporting off but error logging on:

ini_set("display_errors", 0);
ini_set("log_errors", 1);
ini_set("error_reporting", E_ALL &~E_DEPRECATED);
ini_set("error_log", "error.log");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top