I'm trying to build an interface for building if statements for a project I'm working on, and I've came to a conclusion that the best option for my use case is to use EVAL().Can anyone break my code, inject anything or find a better solution for this specific task, that I might be missing?Here's the code on a sandbox.I tried my best to leave comments on the important bits, and here's the code in case this sandbox link is broken in the future:<?error_reporting(E_ERROR | E_PARSE);//Change one of those values to test the if statement$vars['testvar1'] = 1;$vars['testvar2'] = 0;//What to run trough the if statement// [AND\OR, VAR_NAME\TEXT,         OPERATOR,  VAR_NAME\TEXT$if = [   [,     [var => testvar1], ==,        [text => 1]],   [AND,  [var => testvar2], ==,        [text => 1]],];//Builds the statementforeach ($if as $k => $v) {  $first[$k] = $vars[$v[1]['var']] ?? $v[1]['text'];  $second[$k] = $vars[$v[3]['var']] ?? $v[3]['text'];  $st .=  $v[0] \$first[$k] $v[2] \$second[$k] ;}//Shows the generated statementecho if($st)\n;//Evaluates the statementeval(if($st) { \$ok = 1; } else { \$ok = 0; });//Shows if True or Falseecho $ok;
Converting an array to IF() statement using EVAL()
php