note 91841 deleted from function.eval by danbrown
| From: | danbrown@php.net | Date: | Sun, 28 Jun 2009 14:51:21 +0000 |
| Subject: | note 91841 deleted from function.eval by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157645@lists.php.net to get a copy of this message | ||
Note Submitter: cFreed at orange dot fr
----
To jkuckartz1984 at hotmail dot com.
The manual says:
"eval() returns NULL unless return is called in the evaluated code, in which case the value
passed to return is returned."
So if you take it in account, your code works fine:
<?php
$total2=5;
$total3=0;
$i=2;
if (eval("return \$total".$i.";")) {
echo "eval: total2 is full<br>";
} else {
echo "eval: total2 is empty<br>";
}
// returns "full"
?>
(note the addition of "return" inside of eval())