The difference between error and exception access to the online data is mostly Java explanation, seemingly PHP exception handling process and Java almost
The object inheritance structure in Java is as follows:
Object---->throwable--------> Exception ----> runtimeexception | Error
Error is unchecked type exception divided into checked and unchecked types
And to treat the anomalies and errors as the process of abnormal operation of the phenomenon to see
If you distinguish between exceptions and errors:
Exception: not fatal. Try{}catche (Exception e) {} The Try module in execution is a test run that has an error (non-fatal error) executing during the run of the Code Catche
The exception works like the following code:
if (mysql_connect (' 127.0.0.1 ', ' root ', ' 321321 '))
{
echo ' connects the database successfully ';
Other code ...
}
else
{
echo ' connection database error ';
return false;
}
Exceptions can be handled easily by using exception handling. As the following code can handle a lot of exceptions at once
Try
{
mysql_connect (' 127.0.0.1 ', ' root ', ' 321321 ');
Other code for you want to execute
}catche (Exception $e) {
print_r ($e);
}
error : fatal. It's usually a program syntax error or user-level hint error.
Errors and anomalies are divided into checked and unchecked.
Checked can be handled by the user, unchecked is not to be processed
Exception in PHP, user-level errors can be handled by the user (client code) Other errors cannot be handled by the user
In addition, there is a runtimeexception in Java that cannot be handled by the user. This is an exception to the run level.