Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6990467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:21:16+00:00 2026-05-27T19:21:16+00:00

if(true) if($i == 2) callMethodOne(); elseif($i == 3) callMethodTwo(); else { callMethods1(); callMethods2(); //so

  • 0
if(true)
    if($i == 2)
        callMethodOne();
    elseif($i == 3)
        callMethodTwo();
    else
    {
        callMethods1();
        callMethods2();
        //so on
    }
else
    callMethodFiftyFive();      

Is it bad?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:21:17+00:00Added an answer on May 27, 2026 at 7:21 pm

    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:

    if(true)
    {                            // Added this
        if($i == 2)
            callMethodOne();
        elseif($i == 3)
            callMethodTwo();
        else
        {
            callMethods1();
            callMethods2();
            //so on
        }
    }                            // Added this
    else
        callMethodFiftyFive();
    

    I only omit brackets for one-liners, like this:

    if (foo)
        bar();
    

    Never for anything more complicated, like:

    if (foo)
        if (baz)
            spam();
        else
            eggs();
    

    As it is very easy to forget that you’ve omitted the brackets, and add something inside that first “block”:

    if (foo)
        NewCall();
        if (baz)       // WOAH! this now happens regardless of "if (foo)"!
            spam();
        else
            eggs();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

if (exist.IndexOf(true) == -1) { //first condition } else { // second condition }
True or not: We should always use proper capitalization and never put whole sentences
TRUE/FALSE if clauses are easily and quickly done in R. However, if the argument
while (true) { //read in the file StreamReader convert = new StreamReader(../../convert.txt); //define variables
Is it true that the only way to handle default function arguments is through
Under Windows XP WPF true 3D content (which is usually displayed using the Viewport3D
when i use setDefaultLookAndFeelDecorated(true) method in Java why is the Frame appear FullScreen when
I want a true deep copy. In Java, this was easy, but how do
If this is true, I'd like to know why. Do we see a great
Required is the true language version of the OS, not the user interface language

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.