PHP Error Checking

Few ways to check for errors in your PHP

Just when you think you’ve made something foolproof, God makes a better brand of fool. This maxim of manufacturing also applies to software development, especially on a highly accessible technology like web applications. As much as programmers attempt to anticipate every possible action or combination of actions that a user can take when encountering a web application, no one can foresee them all. When the user takes an unanticipated course of action and breaks the application, the software needs to catch them before they fall.


One of the techniques that early PHP programmers used to catch errors was the “die” function. When the program would “die”, this function stops the script and displays an error message. Without the die function, the program would return a specific error message, but not one that users could readily understand. As with other C-based languages (C#, Java, etc.), PHP 5 has a technique for catching exceptions. The keywords “try”, “throw” and “catch” find exceptions and enable better error handling.


Be the first to write a comment

You must me logged in to write a comment.