[solved] if statement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

[solved] if statement

Post by benyboi »

is it possible to have OR's inside an IF statement?

Like:

Code: Select all

if($val1=$val2 or $val3=$val4 ...){...
thanks
Last edited by benyboi on Sat Mar 17, 2007 4:48 pm, edited 1 time in total.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

yea, but you are using assignment operators, not comparison operators.

= vs == and ===
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

doh! nice catch jcart!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Kieran Huggins wrote:doh! nice catch jcart!
It's ok, not every human being has been surgically given eagle eyes. 8)
Post Reply