RE: [PHP] Another problem with conditional statements
| From: | Ford, Mike [LSS] | Date: | Fri, 20 Dec 2002 10:54:39 +0000 |
| Subject: | RE: [PHP] Another problem with conditional statements | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-128966@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Beauford.2002 [mailto:beauford.2002@rogers.com]
> Sent: 20 December 2002 00:19
>
> 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;
Well, I've just cut-and-pasted this code and added a few echo statements
(and some other twiddles to get suitable values in), and it works perfectly
-- so I'd say your $a and $b aren't getting the values you think they are.
As a firtst step, I suggest you echo them out immediately before the switch
statement and see what you've got.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211