note 67986 deleted from function.eval by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 19:55:44 +0000 |
| Subject: | note 67986 deleted from function.eval by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155295@lists.php.net to get a copy of this message | ||
Note Submitter: alerante at bellsouth dot net
----
Regarding the problem posted by jkuckartz1984 at hotmail dot com: you must return a value in the
eval'd code block, so the code really should be
<?php
if (eval("return \$total".$i.";")) {
echo "eval: total2 is full<br>";
} else {
echo "eval: total2 is empty<br>";
}
?>
However, this is really a job for "variable variables" < http://php.net/variables.variable >:
<?php
$varname = "total$i";
if ($$varname) {
[...]
}
?>