Any way to exit outer function from within inner function? Any way to exit outer function from within inner function? wordpress wordpress

Any way to exit outer function from within inner function?


Throw an exception in funcB that is not handled in funcA


<?php  function funcA() {     try     {        funcB();        echo 'Hello, we finished funcB';     }     catch (Exception $e)      {        //Do something if funcB causes an error, or just swallow the exception     }  }  function funcB() {     echo 'This is funcB';     //if you want to leave funcB and stop funcA doing anything else, just     //do something like:     throw new Exception('Bang!');  }?>


The only way I see is using exceptions:

function funcA() {    funcB();    echo 'Hello, we finished funcB';}function funcB() {   throw new Exception;   echo 'This is funcB';}?><p>This is some text. After this text, I'm going to call funcA.</p><p><?php  try { funcA(); } catch (Exception $e) {} ?></p><p>This is more text after funcA ran.</p>

Ugly, but it works in PHP5.