Thread: case statement
View Single Post
  #5 (permalink)  
Old August 18th, 2003, 09:59 PM
richard.york's Avatar
richard.york richard.york is offline
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Quote:
quote:switch statement is used instead of many if...else.
problem causes your case "D","W": you gotta have those separate...
Actually,
this is not entirely true. I wrote a few test scripts using the switch control structure, and found that the 'OR' or '||' operator worked fine within a switch control structure... as well as with the other operators... so in your case you could use:

Code:
switch($new_t1) {

    case "D" || "W":

        if ($new_p1<1 OR $new_p1>30) {

            $t1_errMsg = "The number of billing cycle days/weeks must be between 1 and 30";
        }
    break;
}
I found no discussion of this in the PHP manual under control structures, however this worked fine in my test script.

: )
Rich


:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote