I am currently using the register_shutdown_function () function for several purposes. One use is for handling fatal errors, while the other is for logging resources used at runtime, such as time, memory, etc.
I am currently registering two different shutdown functions, but on one test only the first ran, and the other seems to have failed. Now this may be caused by some error inside the function itself, so I rewrote it, but is it possible that the error is caused by using several calls to register_shutdown_function? So, what is considered the best practice here, for registering two different functions or just for calling one function that handles different tasks?
Is it also safe (and possible) for a function to load a class to handle errors if a fatal error occurs, or should I keep the functionality inside the function itself?
The last question I got is a better way to deal with fatal errors than using the shutdown features? I tried using set_error_handler, but it does not cover all errors, so some errors will not trigger this.
I hope that these questions are well formulated and understandable. My goal is to keep the code as solid as possible, and I could not find decent answers to the questions that I had.
* Edit: I found the answer to my first question, registering several functions should not be a problem, so the error should be in the function itself. Leaving the question to get answers to the question, are there more efficient ways to handle fatal errors.
Sonre source share