Quoting Jason Wong <[EMAIL PROTECTED]>:

> On Thursday 21 November 2002 01:34, Ryan Gallagher wrote:
> 
> > 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.
> 
> The above would not have the intended effect. My boolean maths is extremely 
> rusty but I think it is equivalent to saying:
> 
>   if (!($_GET['sc'] == 2  AND  $_GET['sc'] == 8))
> 
> Which means your code above is *always* TRUE, so do foo is always executed!
> 
> In any case you can easily test it by mentally plugging in values 1 to 8 for
> 
> $_GET['sc'] and evaluating it for yourself.

I'll shut up now, teaches me to reply to this list too early in the morning and
without coffee. ;-)

BTW, what I posted would ALWAYS execute, because of _OR_.  If it's 2, then it's
not 8, so one of the two sides would be true.

Here's a corrected one:

if( ( $_GET['sc'] != 2 ) AND ( $_GET['sc'] != 8 ) ){
   /*
    * Do Foo provided sc is anything but a 2 or 8
    */
   do foo;
 }

-- 
Ryan T. Gallagher
[EMAIL PROTECTED]
International Studies Abroad
http://www.studiesabroad.com
(512)480-8522



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

Reply via email to