le007 Posted October 15, 2007 Share Posted October 15, 2007 Can't find on google how to do an if statement like this: if a = b or a = c or a = d does it have to be if else? Also if a = b and b = c??? Dunno how to do these if's in php yet? Thanks, Leo Link to comment https://forums.phpfreaks.com/topic/73368-solved-another-if-statement-prob/ Share on other sites More sharing options...
simcoweb Posted October 15, 2007 Share Posted October 15, 2007 if((a == b) || (b == c)){ echo "execute your code here"; } else { echo "nothing equalled anything"; } if((a == b) and (b == c)) { echo "execute your code here"; } else { echo "nothing matched so nothing done"; } Link to comment https://forums.phpfreaks.com/topic/73368-solved-another-if-statement-prob/#findComment-370154 Share on other sites More sharing options...
kenrbnsn Posted October 15, 2007 Share Posted October 15, 2007 You're best bet is to read the PHP manual Some examples: <?php if ($a == $b || $a == $c || $a == $d) echo 'ok'; if ($a == $b && $a == $c) echo 'also ok'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/73368-solved-another-if-statement-prob/#findComment-370158 Share on other sites More sharing options...
coder_ Posted October 15, 2007 Share Posted October 15, 2007 I'm to slow to post.. P.S. Did you RTFM??? Link to comment https://forums.phpfreaks.com/topic/73368-solved-another-if-statement-prob/#findComment-370159 Share on other sites More sharing options...
le007 Posted October 15, 2007 Author Share Posted October 15, 2007 Thanks for reply - would this work? if (a == b || a == c){ Also whats ! for? Thanks! Link to comment https://forums.phpfreaks.com/topic/73368-solved-another-if-statement-prob/#findComment-370160 Share on other sites More sharing options...
kenrbnsn Posted October 15, 2007 Share Posted October 15, 2007 Variables in PHP start with a "$". The "!" is the "not" operator. Ken Link to comment https://forums.phpfreaks.com/topic/73368-solved-another-if-statement-prob/#findComment-370163 Share on other sites More sharing options...
le007 Posted October 15, 2007 Author Share Posted October 15, 2007 Ok thanks everyone - I'll read up but the above info has helped and solved the problem! Cheers, Leo Link to comment https://forums.phpfreaks.com/topic/73368-solved-another-if-statement-prob/#findComment-370166 Share on other sites More sharing options...
simcoweb Posted October 15, 2007 Share Posted October 15, 2007 I can't believe I forgot the $'s. Link to comment https://forums.phpfreaks.com/topic/73368-solved-another-if-statement-prob/#findComment-370175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.