Re: How to: If($var != '#' OR '#')

From: Date: Wed, 20 Nov 2002 17:34:45 +0000
Subject: Re: How to: If($var != '#' OR '#')
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-125277@lists.php.net to get a copy of this message
Quoting Jami <jami@jamisniche.com>: > I have code that says: > > if($_GET['sc'] != '2' OR '8'){ > do this..... > } > > but I doesn't work. What do I need to do to get it to work? I have checked > operator precendence and all that and am still confused on whether I should > be using '||' or 'OR' or something else... I have tried both of those, as > well as 'XOR' and '^'. Help please! > > Jami Try: if( ( $_GET['sc'] != 2 ) OR ( $_GET['sc'] != 8 ) ){ /* * Do Foo provided sc is anything but a 2 or 8 */ do foo; } Assuming of course that you meant to exclude cases of 2 or 8. It's a bit hard to tell what your intended event for 8 is. -- Ryan T. Gallagher ryan@studiesabroad.com International Studies Abroad http://www.studiesabroad.com (512)480-8522

« previous php.general (#125277) next »