The finally of PHP

Source: Internet
Author: User
Tags try catch
This article is mainly about PHP Finally, has a certain reference value, now share to everyone, the need for friends can refer to

Finally is the keyword that was introduced in the php5.5 version. Finally is not the original PHP, C #, Javascript, Java. And so on other languages, PHP's finally is similar to other languages.

Regarding the try catch finally syntax, we primarily care about its execution order:


try {//execute code, where there may be an exception. Once an exception is found, jump to catch execution immediately. Otherwise, the contents of the catch will not be executed}

catch {//unless the execute code inside the try has an exception, the code here does not execute}

finally {//No matter what happens, including a return in the try catch, it is understood that if a try or catch is executed, it will be executed finally}

It is important to note that if finally contains return, it overwrites the return in the try or catch.


Reference:

Https://www.cnblogs.com/aspirant/p/6789040.html?utm_source=itdadao&utm_medium=referral

Https://www.cnblogs.com/muzidiandian/p/7026557.html

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.