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

From: Date: Wed, 20 Nov 2002 18:41:41 +0000
Subject: Re: How to: If($var != '#' OR '#')
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-125280@lists.php.net to get a copy of this message
Hiya, On Wed, Nov 20, 2002 at 11:24:11AM -0600, Jami wrote: > 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! It won't work 'cause you're asking two different questions: 1. if $_GET['sc'] != 2, and 2. 8 Operators can only work on two operands, i.e. one either side, so you if you want to ask any more questions, like above, you have to split them each into their own question: if ($_GET['sc'] != '2' || $_GET['sc'] != 8) { It also works the same when looking for a range like '2 < $x < 6', it has to be two questions - '2 < $x && $x < 6'. Hope that helps! :) -- Jonathan Wright.. // mail@djnauk.co.uk // www.djnauk.co.uk -- // life has no meaning unless we can enjoy what we've been given

« previous php.general (#125280) next »