PHP error handling with exit

Just to add, that I’ve tried placing the if statements in functions and do loops to leverage the use of return; and break; instead of exit(); but the problem persists.