Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Catch of Server Errors with PHP

my answer is quite simple: Is there a way to catch server-errors (like Error 400, 401, 403, 404, 500...) automatically with PHP and generate custom Error-Pages.

For example, let's say I got a PHP-File with the page and it just inserts the Error-Code and the Error-Message.

Thanks in advance!

like image 373
TheLexoPlexx Avatar asked Mar 03 '26 20:03

TheLexoPlexx


1 Answers

You may use custom exception handler function (set_exception_handler()) and error handler (set_error_handler()) for turn errors to Exception (example)

like image 151
Nick Avatar answered Mar 06 '26 08:03

Nick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!