skyer2000 Posted September 14, 2007 Share Posted September 14, 2007 I have the following code and cannot figure out why the second check doesn't perform, any ideas? if($stuff != 'foo1' || $stuff != 'foo2') { echo "oh hey"; } else { echo "hi"; } Quote Link to comment https://forums.phpfreaks.com/topic/69385-problem-with-multiple-conditions-in-an-if-statement/ Share on other sites More sharing options...
phat_hip_prog Posted September 14, 2007 Share Posted September 14, 2007 try: if ( ($stuff != 'foo1') || ( strcmp($stuff, 'foo2') != 0 ) { echo "oh hey"; } else { echo "hi"; } Quote Link to comment https://forums.phpfreaks.com/topic/69385-problem-with-multiple-conditions-in-an-if-statement/#findComment-348625 Share on other sites More sharing options...
Jessica Posted September 14, 2007 Share Posted September 14, 2007 What do you mean it doesn't perform? If it matches on the first one it doesn't need to check the second. What is the value of $stuff? Quote Link to comment https://forums.phpfreaks.com/topic/69385-problem-with-multiple-conditions-in-an-if-statement/#findComment-348628 Share on other sites More sharing options...
phat_hip_prog Posted September 14, 2007 Share Posted September 14, 2007 Yeah your original does work (I'm just a sticker for brackets, nice and clear) Quote Link to comment https://forums.phpfreaks.com/topic/69385-problem-with-multiple-conditions-in-an-if-statement/#findComment-348648 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.