Is it ok to leave out the final else statement in an elseif block in PHP. Is this code OK
if ( condition ):
// code
elseif ( othercondition ):
// more code
endif;
or should it have else at the end ?
if ( condition ):
// code
elseif ( othercondition ):
// more code
else
// more code
endif;
I’m sure it must be but I cant get it confirmed anywhere. Edit – I’ve tried it and it works but I just want to be sure.
if you don’t need a final
else-block, don’t write one. it’s just senseless to have a block of code (possibly containing just athis is useless-comment) that isn’t needed.