note 27566 added to control-structures.switch
| From: | njones at rack1 dot php dot net | Date: | Wed, 11 Dec 2002 07:56:05 +0000 |
| Subject: | note 27566 added to control-structures.switch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40750@lists.php.net to get a copy of this message | ||
Running: PHP4.03pl1 - Linux - Apache
I'm not sure if this is how the switch is suppose to work? But when you are evaluating a (TRUE
or FALSE) for the switch while doing a long series of checks (so you have no "break;"
statements) you may run into the problem that once the switch has hit the value you have set, it
will not evaluate the following case statements correctly.
so...
switch (TRUE) {
case not TRUE: // not TRUE
case not TRUE: // not TRUE
case TRUE: // TRUE -- Do Statement
case not TRUE: // TRUE -- Do Statement
case not TRUE: // TRUE -- Do Statement
...
}
What I ended up doing is splitting my switch condition in logical areas to reset when I knew that
there could be a TRUE trigger.
--
http://www.php.net/manual/en/control-structures.switch.php
http://master.php.net/manage/user-notes.php?action=edit+27566
http://master.php.net/manage/user-notes.php?action=delete+27566
http://master.php.net/manage/user-notes.php?action=reject+27566