Re: Another problem with conditional statements
| From: | Rick Emery | Date: | Fri, 20 Dec 2002 00:33:32 +0000 |
| Subject: | Re: Another problem with conditional statements | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128925@lists.php.net to get a copy of this message | ||
switch() does not work that way. Switch uses the value in the parentheses and selects a
CASE based upon that value. Read the manual.
You will have to use a series of if()-elseif()-else()
----- Original Message -----
From: "Beauford.2002" <beauford.2002@rogers.com>
To: "PHP General" <php-general@lists.php.net>
Sent: Thursday, December 19, 2002 6:19 PM
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