Mutley Posted July 31, 2007 Share Posted July 31, 2007 Is it possible to check multiple variables in an IF statement at once? Like instead of doing: if($this == NULL || $that == NULL || $thing == NULL) todo something like if($this, $that, $thing == NULL) Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/62724-if-listing/ Share on other sites More sharing options...
redarrow Posted July 31, 2007 Share Posted July 31, 2007 use a switch or wht you got already ok Quote Link to comment https://forums.phpfreaks.com/topic/62724-if-listing/#findComment-312199 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 I would have thought that the way to do that is like: if ($this is NULL || $that is NULL || $thing is NULL) { echo "do something"; } Quote Link to comment https://forums.phpfreaks.com/topic/62724-if-listing/#findComment-312201 Share on other sites More sharing options...
Mutley Posted July 31, 2007 Author Share Posted July 31, 2007 The problem with doing == NULL for each one is that it takes too much code, can't I just do == NULL once? And just list them. Quote Link to comment https://forums.phpfreaks.com/topic/62724-if-listing/#findComment-312205 Share on other sites More sharing options...
realjumper Posted July 31, 2007 Share Posted July 31, 2007 I'm pretty sure that if you go... if($this, $that, $thing is NULL) { echo "do something"; } ...and (say) $this actually *is* NULL, then $that and $thing won't even be checked because the first part of the if statement is already shown to be true.... $this = 'NULL'; if($this, $that, $thing is NULL) { echo "do something"; } ...so in the above $this actually is NULL so the statement is already true and $that and $thing won't even be looked at by the statement. Quote Link to comment https://forums.phpfreaks.com/topic/62724-if-listing/#findComment-312211 Share on other sites More sharing options...
AndyB Posted July 31, 2007 Share Posted July 31, 2007 Is it possible to ... Tell me, what happened when you tried it? Quote Link to comment https://forums.phpfreaks.com/topic/62724-if-listing/#findComment-312294 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.