|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-09-25 02:04 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
-Package: PHP Language Specification
+Package: Scripting Engine problem
[2016-09-25 02:04 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 23:00:01 2026 UTC |
Description: ------------ While using try catch and finally, the function returns the instruction which is mentioned in finally block. It is prohibitted in .Net, gives syntax error and logically return statement should be a syntax error if used in finally block. I wrote a function which returns and increment by 1 in argument variable and increment by 2 in finally block. Whenever i the function it returs variable incremented by 2 i.e finally block instruction. Test script: --------------- function incrementVar($x) { try{ return ++$x; }catch($e){} finally{ return $x+2; } } echo incrementVar(1); Expected result: ---------------- 2 Actual result: -------------- 3