Jump to content

(update - no reply needed) default executing even when switch case value is met


Malkavbug

Recommended Posts

You know I am probably taking the wrong approach to this to begin with but here we go

You can see what I am trying to do in the code (stripped down with comments)
[code]
  switch (@$forum)
    /*Open of forum switch*/
    {
      case "general": /*Should be ?forum=general */
                       switch (@$view)
                              /*Open of view switch*/
                              {
                                case "topics":
                                /*Should be ?forum=general&view=topics*/
                                    {
                                       echo "viewtopics General wheeee ";
                                     /*Temp to see if it is working*/
                                     break;  /* ends ?= caseblock */
                                    }
                                case "posts":
                                /*Should be ?forum=general&view=posts*/
                                    {
                                       echo "viewposts General wheeee yippie!! ";
                                     /*Temp to see if it is working*/
                                     break; /* ends ?= caseblock */
                                    }
                              }
                              /*End of view switch*/
                       default: echo "Gen Default ";
                       break; /* ends ?= caseblock */
   }[/code]

The problem is.....

Actually, now that I look at it the problem is that I am an idiot.

Default is executing because I never broke the switch prior to it hitting that line
default: echo "Gen Default ";
break; /* ends ?= caseblock */
changed to
break; /* ends ?= caseblock */
default: echo "Gen Default ";

Works just fine.

So I will just post this for other newbies like myself to reference and learn from my initial mistake.

Love you guys here :P
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.