HP7 implements a global Throwable interface, the original exception and part of the error implement this interface (interface), the interface to define the way the exception of the inheritance structure. As a result, more error in PHP7 becomes a exception that can be captured and returned to the developer, error if not captured, if the capture becomes a exception that can be processed within the program. These can be captured error is usually not a fatal damage to the program error, such as the function does not exist.
One, there are now two exception classes: Exception and Error.
PHP7 now has two exception classes, Exception and Error. All two classes implement a new interface: Throwable. In your exception handling code, type hinting may need to be adjusted.
<?php
try {
Not_exists_func ();
catch (Engineexception $e) {
Var_dump ($e->getmessage ());
}
Output
String "Call to undefined function not_exists_func ()"
Second, some fatal errors and recoverable fatal errors are instead thrown at the error object.
Some fatal errors and recoverable fatal errors are now reported to the Error object. The error objects are independent of the exception, and they cannot be caught by conventional try/catch. Editor's note: You need to register the error handling function, please refer to the following RFC.
The recoverable fatal error that has turned into an exception cannot be ignored silently by the error handler. In particular, type hinting errors cannot be ignored.
Third, the grammatical error will throw a ParseError object
A syntax error throws a ParseError object that inherits from the Error object. When you process eval (), you should also capture the ParseError object in addition to checking the return value or Error_get_last () for potentially incorrect code.
Four, the internal object construction method if it fails, always throws an exception
The construction method of the inner object always reports an exception if it fails. Some previous construction methods return null or an object that cannot be used.
Five, some e_strict wrong level adjustment.