Jump to content

Archived

This topic is now archived and is closed to further replies.

Malkavbug

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

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

Share this post


Link to post
Share on other sites

×

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.