if statement - If() vs. switch() - Same meaning but different behaviour? -


i transform if() conditional switch() this:

if($configuration['application'][$applicationname]['subdomain'] == true){     foreach($configuration['language'] $language){         if($language['abbreviation'].'.'.$configuration['application'][$applicationname]['domain'] == $_server['http_host']){             $_session['language'] = $language['abbreviation'];         }     }      // if no subdomain detected , redirection enabled, set default language     if(!isset($_session['language'])){         $_session['language'] = $configuration['application'][$applicationname]['language'];     } } else {     $_session['language'] = $configuration['application'][$applicationname]['language']; } 

to this:

switch($configuration['application'][$applicationname]['subdomain']){     case true:         foreach($configuration['language'] $language){             if($language['abbreviation'].'.'.$configuration['application'][$applicationname]['domain'] == $_server['http_host']){                 $_session['language'] = $language['abbreviation'];                 break;             }         }     default:         $_session['language'] = $configuration['application'][$applicationname]['language'];         break; } 

i think should same behaves differently ... switch not working ...

i have reformatted code, please check make sure still correct.

as problem, begin missing break; statement @ end of case true: statement. (the break inside foreach loop breaks out of loop, not case itself).


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -