PHP 7 error handling mechanism modification

Source: Internet
Author: User
PHP7 now has two exception classes, ExceptionandError. Both classes implement a new interface: Throwable. In your exception handling code, the type suggestion may need to be adjusted.

I. There are two Exception classes: Exception and Error.

PHP7 now has two Exception classes: Exception and Error. Both classes implement a new interface: Throwable. In your exception handling code, the type suggestion may need to be adjusted.

2. some fatal errors and recoverable fatal errors are changed to throwing Error objects..

Some fatal errors and recoverable fatal errors are now reported as Error objects. Error objects are independent from exceptions and cannot be caught by conventional try/catch objects. Editor's note: To register an error handler, refer to the RFC below.

The error handler cannot silently ignore the recoverable fatal errors that have been converted to exceptions. In particular, you cannot ignore error types.

3. syntax errors will throw a ParseError object

A syntax Error will throw a ParseError object inherited from the Error object. Before processing eval (), the ParseError object should be captured in addition to checking the returned value or error_get_last () for codes with potential errors.

4. internal object constructor will always throw an exception if the constructor fails.

If the internal object constructor fails, an exception is always reported. Some previous constructor methods return NULL or an unusable object.

5. some E_STRICT error levels have been adjusted.

VI. References

Https://wiki.php.net/rfc/engine_exceptions_for_php7

Https://wiki.php.net/rfc/throwableinterface

Https://wiki.php.net/rfc/internal_constructor_behaviour

Https://wiki.php.net/rfc/reclassify_e_strict


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.