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. ...

Get PHP Advanced for the World Wide Web: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.