Re: reversing an IF statement

From: Date: Sat, 01 May 2004 12:12:00 +0000
Subject: Re: reversing an IF statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185093@lists.php.net to get a copy of this message
Kim Steinhaug wrote:
Often I end up using a "dumb" IF statement which to me seems that it could have been done some other way. Example : if(
    ($_GET["id"]==1) or
    ($_GET["mode"]=="home") or
    ((!isset($_GET["item"])) && ($_GET["mode"]=="news"))
) {
    // Here we do nothing
     } else {
    // This is where we do it
    }
Wouldn't it then be like this? if($_GET['id']!=1 && $_GET['mode']!='home' && (isset($_GET['item']) && $_GET['mode']!='news')) // Do stuff. I may be wrong though. Note that I used AND instead of OR for the conditions, because you want them all true at the same time. But then again, you'd have to test it, with so many conditions it becomes a bit difficult to picture it in my head :P HIH, Anguz

« previous php.general (#185093) next »