if(true)
if($i == 2)
callMethodOne();
elseif($i == 3)
callMethodTwo();
else
{
callMethods1();
callMethods2();
//so on
}
else
callMethodFiftyFive();
Is it bad?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I wouldn’t say that it is particularly bad, especially for a small, isolated script. But things like this become problems when you start working with more code, more complex code, and more importantly more programmers.
I would suggest you pick a coding standard and try to adhere to it. For example, PEAR has published their coding standard: Manual :: Coding Standards
Personally, I would at least include brackets around the first block:
I only omit brackets for one-liners, like this:
Never for anything more complicated, like:
As it is very easy to forget that you’ve omitted the brackets, and add something inside that first “block”: