mardi 24 mars 2015

PHP use else after accessing a if

Let's pretend we have a if Statement like:



if(something_true) {
$obj = get(my_obj);
if($obj !== null) do(something_special);
else do(the_default); # First else
}
else do(the_default); # Second else


Is it possible to exit the if at the first else and instead go on with the second else?


My thought behind this is that i don't have to write the exactly same code two times.


Aucun commentaire:

Enregistrer un commentaire