Home > Article > Backend Development > php finally
This article mainly introduces finally about php, which has certain reference value. Now I share it with everyone. Friends in need can refer to it.
finally was introduced in the php5.5 version Keywords. finally is not original to PHP, it is available in other languages such as C#, Javascript, Java, etc. PHP's finally is similar to other languages.
Regarding the try catch finally syntax, we are mainly concerned about its execution order:
try { //The executed code may have exceptions. Once an exception is found, it immediately jumps to catch execution. Otherwise, the content in the catch will not be executed}
catch { //Unless an exception occurs when executing the code in try, the code here will not be executed}
finally { //No matter what the situation is, it will Execution, including the use of return in try catch, can be understood as as long as try or catch is executed, finally will be executed. }
It should be noted that if finally contains return, it will overwrite the try or catch. return.
Reference:
https://www.cnblogs.com/aspirant/p/6789040.html?utm_source=itdadao&utm_medium=referral
https://www.cnblogs.com/muzidiandian/p/7026557.html
Related recommendations:
The above is the detailed content of php finally. For more information, please follow other related articles on the PHP Chinese website!