Re: if statement with or comparison (newbie)
| From: | Curt Zirzow | Date: | Mon, 11 Sep 2006 21:01:48 +0000 |
| Subject: | Re: if statement with or comparison (newbie) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241627@lists.php.net to get a copy of this message | ||
On 9/8/06, Robert Cummings <robert@interjinn.com> wrote:
On Fri, 2006-09-08 at 15:30 -0600, Jeremy Privett wrote: Well, it could be this, too: switch( $_REQUEST['id'] ) {I don't know about big and ugly, it seems more clear on what is going on in this situation. But yeah it is best to clearify the switch as you rewrote it. curt.case "white": echo "Right color."; break;case "black": echo "Right color."; break;default: echo "Wrong color."; break;} Ugh, if you're going to use a big ugly case statement for something so trivial at least make use of the fall-through feature: <?php switch( $_REQUEST['id'] ) {case 'white': case 'black': { echo 'Right color.'; break; }