Executing a string in PHP -
i have requirement have conditions saved in db. able bring conditions via php code, not able execute them. have shown 1 example below.
<? $z = ">100";//i value db $x = 80; // value comes db if(exec("&1 &2",$x,$z)) echo "yes"; else echo "no"; ?>
also tried this
<? $z = ">100"; $x = 80; if(eval("$x $z")) echo "yes"; else echo "no"; ?>
it should be, ( eval
accepts statements, not expressions)
$z = ">100";//i value db $x = 80; // value comes db if(eval("return {$x} {$z};")) echo "yes"; else echo "no"; ?>
Comments
Post a Comment