Re: How to: If($var != '#' OR '#')
| From: | electroteque | Date: | Wed, 20 Nov 2002 20:24:26 +0000 |
| Subject: | Re: How to: If($var != '#' OR '#') | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-125320@lists.php.net to get a copy of this message | ||
add to that i'd do this
if ($_GET['sc'] !== '2' || $_GET['sc'] !== 8) {
for me single equals seem to assign the variable with the value double
equals seem to check the variable for the value
"Jonathan Wright" <mail@djnauk.co.uk> wrote in message
news:20021120184141.GA12806@chef...
> 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