I have a php application, that, when it encounters an error, will run a function that uses trigger_error()
as well as uses the following function to return the error as JSON.
$this->returnError('My error');
In some places in the script, multiple errors occur, but only one gets returned, because the returnError()
function will stop the script. So, the errors are not entirely accurate. What I want to do is gather all errors into an array, then at the end of the script send that through JSON so that the use can get nicely formatted JSON of the errors.
So, my question is, what is the best way to go about this? Is this the best idea, or is there a better method of capturing and returning multiple errors?