Answer the question
In order to leave comments, you need to log in
Confusion with error handling and exceptions. How to do it right?
Hello colleagues! I recently went through the topic of PHP error handling and exceptions, and no matter how much I wanted to understand everything, there were still a couple of questions left.
So let's take as an example a situation where a script tries to open a non-existent file with fopen(). By default, the script will throw out a warning that I want to handle. Here I see 2 ways:
Answer the question
In order to leave comments, you need to log in
1. The "ERROR TRACKING SYSTEMS" tag has nothing to do with the question (if so, many tags have descriptions).
2. error suppression does not remove the error itself, and it is necessary to remove not the message about it, but the reason for its occurrence. specifically for fopen - it is enough to check the existence of a file / access to it.
3. set_error_handler and exceptions are different areas, sometimes absolutely.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question