note 67986 added to function.eval
| From: | alerante at bellsouth dot net | Date: | Sat, 08 Jul 2006 17:41:39 +0000 |
| Subject: | note 67986 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114598@lists.php.net to get a copy of this message | ||
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) {
[...]
}
?>
----
Server IP: 216.194.113.175
Probable Submitter: 65.5.197.152
----
X-Spam-Status: No, hits=4.0 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_20_30,HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- http://master.php.net/note/edit/67986
Del: integrated -- http://master.php.net/note/delete/67986/integrated
Del: useless -- http://master.php.net/note/delete/67986/useless
Del: bad code -- http://master.php.net/note/delete/67986/bad+code
Del: spam -- http://master.php.net/note/delete/67986/spam
Del: non-english -- http://master.php.net/note/delete/67986/non-english
Del: in docs -- http://master.php.net/note/delete/67986/in+docs
Del: other reasons-- http://master.php.net/note/delete/67986
Reject -- http://master.php.net/note/reject/67986
Search -- http://master.php.net/manage/user-notes.php