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! 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 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."; } 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. 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"; } ?> 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. 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? 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. 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 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
Archived
This topic is now archived and is closed to further replies.