Exception Handling-PHP manual notes

Source: Internet
Author: User
Exceptions generated in the PHP code can be throwStatement is thrown, and is catchStatement capture. Code that requires exception handling must be placed in the tryWithin the code block, each tryAt least one of the corresponding catch。 When an exception is thrown, the code behind the block of code will not proceed, and PHP will attempt to find the first one to match it. catch。 Of course, PHP allows you to catchThe code block is thrown in again throwAbnormal. If an exception is not captured and is not used set_exception_handler(), PHP will produce a serious error.

Here is an example of the use of exceptions.


  
   ';    echo inverse(0) . '
';} catch(Exception $e) { echo 'Caught exception: ' . $e->getMessage() . '
';}echo 'hello';

There is also an example of an exception nesting.


  
   getMessage());        }    }}$foo = new Test;$foo->testing();

Users can use custom exception handling classes to extend PHP's built-in exception handling classes.

(End of full text)

The above describes the exception handling-PHP manual notes, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.