How to modify all PHP7 error messages?

2

I am finalizing my project and soon I will put the site in my hosting. I do not want my user to see a "Warning" or any other message. Instead I want it to appear: "There was an error, please contact us. If possible, please send a print of the problem."

    
asked by anonymous 20.09.2017 / 23:59

1 answer

1

You can set an exception handler to handle all exceptions or unhandled errors with set_exception_handler , just pass any callable to it:

set_exception_handler(function ($e) {
    echo 'Ocorreu um erro, Entre em contato conosco. Se possível, mande um print do problema.';
    echo 'Mensagem do erro: ' . $e->getMessage();
});
    
21.09.2017 / 03:56