How to exit if statement and continue to else

if-statement, php

Solution

try {
    //do method one

    //error occurs during method one, need to exit and continue to else 
    if ($condition != "good") {
        throw new Exception('foo');
    }
} catch (Exception $e) {
    //do method two

}

Problem

This is a long shot question, but is there a way in php to exit an "if" statement and continue on to the "else" statement if an error occurs inside the if block? example ``` if ($condition == "good") { //do method one //error occurs during method one, need to exit and continue to else } else { //do method two } ``` Of course it is possible to do a nested if inside the first if, but that seems hacky. TIA

Original source