Error Handling¶
Error handling is a broad concept that covers the different ways that PHP uses to signal that an error occurred.
The main systems are the error reporting, and the exceptions.
The error reporting is often associated with native errors, although it is possible to raise them and handle them with error-handlers.
The exception system is based on the throw, try and catch keywords.
<?php
trigger_error('Cannot do this', E_USER_ERROR);
try {
throw new Exception('Cannot do this');
} catch (Exception $e) {
print $e->getMessage();
}
?>
See also PHP Error Handling and Exceptions: Best practices for robust applications.
Related : Exception, Error Handler, Downtime, Fatal Error, Rollback, Troubleshoot, Error Suppression