The functions I have written are throwing exceptions if they can't do their job. For the productive environment I thought to redirect the exception to a nice looking error page. Therefore I'm thinking of setting the exception handler set_exception_handler
on the beginning of every script. How does the error page know which error occured? I thought of putting an error code into the URL like header("Location: error.php?code=1234")
. While in the development phase I just would not set the exception handler, thus every exception would be printed onto the php default error screen Uncaugt Exception: ... with all usefull informations.
I have read Exceptions in PHP - Try/Catch or set_exception_handler? but don't know how to write a front controller script and also think this is maybe to much the effort.
I'm a PHP beginner who likes to handle errors in the right way, but I'm just not sure if I'm doing it right or wrong. Do you think it's ok doing it like above described or do you have other suggestions?
Thank you!