I'm new to PHP so I apologize if this seems silly. I've searched around and couldn't find anything that explained specifically what I'm looking for.
Ultimately I have two goals.
- In production, when an unexpected error occurs, show the user a default "oops" page.
- When an expected error occurs, handle it without PHP dying.
My mental model of PHP error handling is spotty enough that I can't move forward with any confidence and I haven't been able to find any good documentation about the process.
To give some contrived examples.
- user makes a request, connection to the DB fails, we display an oops message.
- user makes a request, script doesn't doesn't parse correctly, we display an oops message.
- user makes a request, we query the DB with an update using optimistic locking. It fails, so we inform the user that the object has been updated.
I think most of my confusion is surrounding what errors result in the script dying and what errors do not (using the default handler), and when the script dies, how do we gracefully inform the user?
Also, do any of the standard php functions/objects use exceptions? If I choose to handle exceptions in more of a C style I'm not going to be surprised at any point am I? Is this going to change in PHP6? If so I'll put forth the effort to paper over the differences between using c style and exceptions, but if not, I'd rather just use the c style consistently throughout PHP5. That is not a problem I am interested in solving unless I absolutely need to.
edit: I just realized the content doesn't quite match the title. I would like to know, when an error occurs, what is the logic flow for PHP? This way I can better understand how to go about achieving my goals with respect to error handling in PHP.