SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: if or switch?

  1. #1
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    if or switch?

    I m executing a chunk of queries, and if that query is executed then i want something else to be excuted. i am confused here to use if or switch. i never did anything like that.
    All those who wander aren't lost.

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,336
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    IF is best suited for a 'binary' choice - one thing OR another. You can extend the IF to include more but the logic (and the code) becomes very confused and convoluted.
    SWITCH (otherwise known as CASE) is ideal when you need to evaluate a single variable and choose from among multiple values.

    Based on your brief post, it seems IF would be best.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •