Page 1 of 1

[solved] if statement

Posted: Sat Mar 17, 2007 4:21 pm
by benyboi
is it possible to have OR's inside an IF statement?

Like:

Code: Select all

if($val1=$val2 or $val3=$val4 ...){...
thanks

Posted: Sat Mar 17, 2007 4:26 pm
by Kieran Huggins
aye lad: http://ca3.php.net/manual/en/language.o ... ogical.php

|| = OR

&& = AND

in both cases, they both work but have different precedences:
http://ca3.php.net/manual/en/language.o ... precedence

What you're doing is ANDing and/or ORing the truth of your assertions.

Posted: Sat Mar 17, 2007 5:15 pm
by John Cartwright
yea, but you are using assignment operators, not comparison operators.

= vs == and ===

Posted: Sat Mar 17, 2007 6:10 pm
by Kieran Huggins
doh! nice catch jcart!

Posted: Sat Mar 17, 2007 6:15 pm
by John Cartwright
Kieran Huggins wrote:doh! nice catch jcart!
It's ok, not every human being has been surgically given eagle eyes. 8)