Its all wrong. You shouldn't be using a switch statement anyway. A switch is for evaluating a single variable.
alss, your code if ($a && $b == 124) is the equivelent of writing if ($a == true && $b == 124). if ($a == $b) { // do struff } elseif ( ($a == 124) && ($b == 124) ) { //do stuff } elseif ( ($a == 124) && ($b == 755) ) { //do stuff } elseif ( ($a == 124) && ($a != $b) ) { // do stuff } else { // do default } a switch statement is used in this context; $a = 1; switch ($a) { case 1: $blah = $a; break; case 2: $blah = 'something else'; break; default: $blah = 'nothing'; } you evaluate a single variable, otherwise, you are stuck with using is/else statements > -----Original Message----- > From: Beauford.2002 [mailto:[EMAIL PROTECTED]] > Sent: Friday, 20 December 2002 11:19 AM > To: PHP General > Subject: [PHP] Another problem with conditional statements > > > Hi, > > This should be as simple as breathing, but not today. I have two variables > $a and $b which I need to compare in a switch statement in > several different > ways, but no matter what I do it's wrong. > > This is what I have tried, can someone tell me how it should be. > > TIA > > switch (true): > > case ($a == $b): This one seems simple enough. > do sum stuff; > break; > > case ($a && $b == 124): This appears not to work. > do sum stuff; > break; > > case ($a == 124 && $b == 755): If $a is equal to 124 and $b > is equal to > 755 then it should be true..doesn't work. > do sum stuff; > break; > > case ($a == 124 && $b != 124): Nope, this doesn't appear to work > either. > do sum stuff; > break; > > endswitch; > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php