> -----Original Message-----
> From: Sean Malloy [mailto:[EMAIL PROTECTED]]
> Sent: 20 December 2002 02:36
> To: PHP General
> Subject: RE: [PHP] Another problem with conditional statements
> Nowhere in the documentation does it specify switch should be 
> used in the
> context you are attempting.

The docs say:

 "In many occasions, you may want to compare the same variable
  (or expression) with many different values, and execute a
  different piece of code depending on which value it equals
  to. This is exactly what the switch statement is for."

TRUE is an expression, and so can be the subject of a switch statement. 

> The docs show a single variable and checking the case of that 
> variable.

Admittedly all the examples in the manual use a single variable, but from the first 
sentence of the switch description:

 "The switch statement is similar to a series of IF statements
  on the same expression."

... I think it's reasonable to deduce that the parentheses after switch can contain 
any legitimate expression.

Admittedly, all the examples in the manual use a single variable -- perhaps you might 
want to submit a Documentation Problem bug report suggesting some more complex 
examples.  Actually, looking at the online manual again, I see several user notes with 
potential candidates for moving to the manual proper, including one which demonstrates 
the exact usage that the OP was having problems with.



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
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to