What is the difference between an error and an exception?
I have read numerous resources online and in a couple of books, but the explanations provided are not very thorough. As such, I am still confused.
Thanks!
Edit:
It looks like I asked two questions which was probably confusing. The main question that I wanted an answer to is the difference between errors and exceptions. So, I have edited the above to be more specific. Thanks everybody for your answers.
There is no “should” or “best” way to do error handling.
Generally speaking, there are two types of errors
Notice that neither of these have anything to do with the specific PHP mechanisms you’d use to handle errors.
If you use exceptions…
Then I recommend using exceptions across the board. Register an exception handler and let it do most of the work – including other PHP errors. Invalid login details?
Then you have a bunch of choices for implementation.
Or, if you so choose, let the exception handler do it. Maybe even in a more flexible way
Then, in the exception handler
But exceptions aren’t the only way, and by some not even considered a good way.