jump out of a finally block is disallowed

Description

It is not possible to make a goto, when the label is in a finally block. It is OK to do the goto call when both goto and label are in the finally block, though.

Example

<?php


try {}
catch (Exception) {}
finally {
     goto theLabel;
}

     theLabel:
             $a++;

?>

Solutions

  • Replace the goto call with something else.

  • Move the goto after the finally block.

  • Move the label in the finally block.