Tons of {}.. better way?
Posted: Sun Jul 02, 2006 7:01 pm
Alright, say you have something like this:
and so on.
Might it be better to do something like this? (I don't how to do gotos in php, by the way.)
Not that I particularly like gotos...
Or is there an even better way? I ask because getting so many brackets becomes annoying.
I'm basically doing error checking, but I don't want to die() if I find an error--I just want to stop what I'm doing and go to the next thing.
Would something like this be possible? (Just came to me...)
Code: Select all
if ($a) {
//stuff
if ($b) {
//stuff
if ($c) {
//stuff
if ($d) {
//finish
}
}
}
}Might it be better to do something like this? (I don't how to do gotos in php, by the way.)
Code: Select all
if (!$a) goto quit;
//stuff
if (!$b) goto quit;
//stuff
if (!$c) goto quit;
//...
:quitOr is there an even better way? I ask because getting so many brackets becomes annoying.
I'm basically doing error checking, but I don't want to die() if I find an error--I just want to stop what I'm doing and go to the next thing.
Would something like this be possible? (Just came to me...)
Code: Select all
{
if (!$a) break;
//stuff
if (!$b) break;
//...
}