Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Please correct me if i wrong, but from your code above, when you eval you $condition string, you put it back again into $condition. Unless your evaluated code have "return" in it, it will return null ( reff : <a href="http://php.net/manual/en/function.eval.php" rel="nofollow">http://php.net/manual/en/function.eval.php</a>).</p> <p>But your problem is actually miss-use of " on $condition. When you use " to wrap string(s) on php, it will change every variable on that string to the value defined for that variable above that code.</p> <p>So, instead having your code evaluate by php, you're actually sending wrong code to eval().</p> <p>your current $condition code is :</p> <pre><code>if(HD&lt;&gt;'99' &amp;&amp; HD&lt;&gt;'XX' &amp;&amp; HD&lt;&gt;'XM' &amp;&amp; HD&lt;&gt; 'XD' &amp;&amp; HD&lt;&gt; 'XY' &amp;&amp; HD&lt;&gt; 'XE') { echo 'YES'; } else { echo 'NO'; } </code></pre> <p>and what you're trying to achive is :</p> <pre><code>if($status&lt;&gt;"99" &amp;&amp; $status&lt;&gt;"XX" &amp;&amp; $status&lt;&gt;"XM" &amp;&amp; $status&lt;&gt; "XD" &amp;&amp; $status&lt;&gt; "XY" &amp;&amp; $status&lt;&gt; "XE") { echo "YES"; } else { echo "NO"; } </code></pre> <p>Please change " to ' since string(s) wrap in ' will be as it is (if you want to put ' inside it, please escaped it using backslash (\) ) and see what happen.</p> <p>my work around :</p> <pre><code>$status = "HD"; $vari = "XX"; $condition = 'if($status&lt;&gt;"99" &amp;&amp; $status&lt;&gt;"XX" &amp;&amp; $status&lt;&gt;"XM" &amp;&amp; $status&lt;&gt; "XD" &amp;&amp; $status&lt;&gt; "XY" &amp;&amp; $status&lt;&gt; "XE") { echo "YES"; } else { echo "NO"; }'; eval($condition ); echo $condition; echo "&lt;hr&gt;"; $resp = str_replace('status','vari',$condition); eval($resp); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload