How to modify all PHP7 error messages?

Asked

Viewed 49 times

2

I am finalizing my project and soon I will put the site in my hosting. I don’t want my user to see a "Warning" message or any other. Instead I want it to appear: "An error has occurred, Contact us. If possible, send a print of the problem."

  • 1

    Does that help you? https://answall.com/q/34814/5878

  • Can’t change the PHP7 settings to modify the error text? php.ini or something like that?

  • I believe not and it does not seem feasible.

  • Okay, I’ll try here then, vlw!

1 answer

1


It is possible to define a Exception Handler to manipulate all exceptions or errors not dealt with set_exception_handler, just pass any callable for him:

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();
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.