Switch/Case not working PHP -


I'm trying to enter the habit of using the switch I have the following tidbit: < pre> switch ($ res ['perm']) {case '0': $ perm = "Invalid"; Case '1': $ perm = "operator"; Case '2': $ perm = "Team Lead"; Case '3': $ perm = "Admin"; Default: $ perm = "Unknown -". $ Res ['perm']; }

Where $ res ['perm'] = (int) 3 .. I tried even without single quotation marks, but it is still "unknown "" .. what am I doing wrong?

you break Required to be hit by switch or it will always kill default :

  switch ($ res ['perm']) {case ' Case '2': $ perm = "Team Lead"; breakdown; Case '3': $ perm = "$ ': $ perm =" invalid "; rupture; case' 1 ': $ perm =" operator "; Admin "; break; default: $ perm =" unknown - ". $ Res ['p erm '];}    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -