title: Using a string variable as the condition of an if statement in php without using eval()
body: <p>My condition is generated by the code into a string to look like:</p>
  
  <pre><code>$mycondition = "(strpos(strtolower($foo1), strtolower($bar)) !== false) AND (strpos(strtolower($foo1),  strtolower($bar2)) !== false) // AND ((strpos(strtolower($foo2),  strtolower($bar1)) !== false)) AND..."; ad infinitum
  </code></pre>
  
  <p>My if statement should be like:</p>
  
  <pre><code>if ($mycondition) then...
  </code></pre>
  
  <p>I can do it with eval() like so:</p>
  
  <pre><code>if (eval("return $mycondition;")) then...
  </code></pre>
  
  <p>But I understand eval() is not recommended practice. On searching the forum, I see many voices calling against the use of eval(), but not really many alternatives.</p>
  
  <p>What's the alternative? How do I just place the generated string into the if condition?</p>