Re: if statement with or comparison (newbie)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/8/06, Robert Cummings <robert@xxxxxxxxxxxxx> wrote:
On Fri, 2006-09-08 at 15:30 -0600, Jeremy Privett wrote:
> Well, it could be this, too:
>
> switch( $_REQUEST['id'] ) {
>       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;
    }

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.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux