Error Logging and Reporting
By now most programmers know that errors are going to happen. The key is how to best handle them.
The first recommendation is to incorporate @ and die() in your scripts. The former is used for function calls that could not work but which you do not want to stop the execution of your script. Examples would be a case where nothing is returned from a database query or a file could not be opened. The latter, die(), should be used with any action for which an unsuccessful execution essentially renders the progression of the script moot. If you cannot connect to a database or query it, there is probably no need to continue. The great benefit of die() is that you can use it to not only stop the script but also report an error. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access