Error handling is an important part of any real-world application. PHP provides a number of mechanisms that you can use to handle errors, both during the development process and once your application is in a production environment.
Normally, when an error occurs in a PHP script, the error message is inserted into the script’s output. If the error is fatal, the script execution stops.
There are three levels of conditions: notices , warnings , and errors. A notice is a condition encountered while executing a script that could be an error but could also be encountered during normal execution (e.g., trying to access a variable that has not been set). A warning indicates a nonfatal error condition; typically, warnings are displayed when calling a function with invalid arguments. Scripts will continue executing after issuing a warning. An error indicates a fatal condition from which the script cannot recover. A parse error is a specific kind of error that occurs when a script is syntactically incorrect. All errors except parse errors are runtime errors.
By default, all conditions except runtime notices are caught and
displayed to the user. You can change this behavior globally in your
php.ini file with the
error_reporting option. You can also locally
change the error-reporting behavior in a script using the
error_reporting( ) function.
With both the
option and the
error_reporting( ) function, you specify the conditions that are caught and displayed ...