Is this IF ok? Or is there a better way? So, I wanted to avoid an

if (...) { }
else if (...) { }
else { }


scenario to avoid duplicating code. After a little playing, I got the following working (works from the testing i've done). Am wondering if anyone has any feedback on this approach or suggestions on on possible improvement?

Sometimes I think I know what I'm doing, sometimes I don't.

&lt;?php

  // define("MEMBER_LIMIT",0); // no member limit
defined("MEMBER_LIMIT",100); // limit to 100 ppl in group

  // $memcount is set via sn SQL query
$memcount = 9; // number of people currently in group (let's say).

if (!defined("MEMBER_LIMIT") ||
 ((defined("MEMBER_LIMIT") &amp;&amp; MEMBER_LIMIT == 0) || 
  (MEMBER_LIMIT &gt; 0 &amp;&amp; $memcount&gt;0 &amp;&amp; $memcount &lt; MEMBER_LIMIT))) {
  // will do something
}
else {
  // will do something else.
}
?&gt;
How about:

if (!defined("MEMBER_LIMIT") ||  MEMBER_LIMIT == 0 || $memcount &lt; MEMBER_LIMIT) {
  // will do something
}
else {
  // will do something else.
}


The key is to look for both complementary (multiple items that accomplish the same thing by different means) and contradicting criteria (which would interrupt your desired flow of logic) in if statements