Tovin Posted January 15, 2008 Share Posted January 15, 2008 Alright, I've written a script with an IF and ELSE statement and I was wondering if there was a way to make two IF variables. What I'm trying to get my script to do is this: Read two columns and if either of those are true then echo one thing or else echo something different. Is there some sort of OR statement? if ( $variable1 == 0 or $variable2 == 10) { echo "blah here."; } else { echo "other stuff."; } I hope that makes sense. I know that the code above doesn't work, I was just wondering how to make it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/86087-solved-quick-if-else-statement-question/ Share on other sites More sharing options...
naveenbj Posted January 15, 2008 Share Posted January 15, 2008 Can you post the full code here?? Regards, nj Quote Link to comment https://forums.phpfreaks.com/topic/86087-solved-quick-if-else-statement-question/#findComment-439569 Share on other sites More sharing options...
p2grace Posted January 15, 2008 Share Posted January 15, 2008 Try this: if ( $variable1 == 0 || $variable2 == 10) { echo "blah here."; } else { echo "other stuff."; } Quote Link to comment https://forums.phpfreaks.com/topic/86087-solved-quick-if-else-statement-question/#findComment-439570 Share on other sites More sharing options...
Tovin Posted January 15, 2008 Author Share Posted January 15, 2008 Awesome. Let me try that out. Quote Link to comment https://forums.phpfreaks.com/topic/86087-solved-quick-if-else-statement-question/#findComment-439573 Share on other sites More sharing options...
Lukela Posted January 15, 2008 Share Posted January 15, 2008 What the guy said above <?php || = OR && = AND if( $var1 == soandso || $var2 == soandso) { echo "so and so"; } else { echo "so and so"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/86087-solved-quick-if-else-statement-question/#findComment-439574 Share on other sites More sharing options...
Tovin Posted January 15, 2008 Author Share Posted January 15, 2008 Thank you so much! Exactly what I needed. Quote Link to comment https://forums.phpfreaks.com/topic/86087-solved-quick-if-else-statement-question/#findComment-439575 Share on other sites More sharing options...
naveenbj Posted January 15, 2008 Share Posted January 15, 2008 What the guy said above <?php || = OR && = AND if( $var1 == soandso || $var2 == soandso) { echo "so and so"; } else { echo "so and so"; } ?> "|| = OR && = AND" This linesdosent make any sense Isnt it? Quote Link to comment https://forums.phpfreaks.com/topic/86087-solved-quick-if-else-statement-question/#findComment-439576 Share on other sites More sharing options...
p2grace Posted January 15, 2008 Share Posted January 15, 2008 He was just showing the syntax for "or" and "and" for if statements. Quote Link to comment https://forums.phpfreaks.com/topic/86087-solved-quick-if-else-statement-question/#findComment-439578 Share on other sites More sharing options...
naveenbj Posted January 15, 2008 Share Posted January 15, 2008 He was just showing the syntax for "or" and "and" for if statements. Ohk Regards , Nj Quote Link to comment https://forums.phpfreaks.com/topic/86087-solved-quick-if-else-statement-question/#findComment-439579 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.