PHP IF OR question

Hi,

I am writing an if statement and it evaluates as follows …

if((true) || (true) || (false))

It returns as true? why is this when there is a false?

Problem sorted needed to use

((true || true) && false)

true || false => true

true && false => false

See PHP Logical Operators in the manual.

When using "OR"s (||) only one of the expressions need to be true to reduce to the expression being true. In your example it would reduce to:

((true||true)||false) => ((true)||false) => (true)

with "AND"s (&&), all of the expressions have to be true to reduce to the expression to be true

((true&&true)&&false) =>((true)&&false) => (false)

So in short:

true&&true => true

true&&false => false

false&&false => false

true||true => true

true||false => true

false||false => false

mixing and matching || and && can sometimes get tricky but parenthesis always help to better understand things. :)

-Nazum

Thanks everyone.