note 53761 deleted from function.eval by sean

From: Date: Sun, 12 Jun 2005 12:52:16 +0000
Subject: note 53761 deleted from function.eval by sean
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-90302@lists.php.net to get a copy of this message
Note Submitter: dale at mlmservices dot co dot uk Reason: bad code ---- I had a requirement to pull in parameters from a database as well as the code needed to run. What to do, what to do. So I created a function that calls eval() twice - once to insert the params and once to run the code with the params inserted. Here it is for readability. <?php $args[0] = '400'; $args[1] = '200'; $func_code = "return max($args[0], $args[1]);"; // Note "return" keyword must be used echo testeval($args, $func_code); function testeval($args, $func_code) { eval($str = $func_code); // Insert params into code return eval($str); // execute code } ?> I hope this helps somebody :)

« previous php.notes (#90302) next »