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

Archived

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

×
×
  • 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.