note 91841 added to function.eval

From: Date: Sun, 28 Jun 2009 09:59:16 +0000
Subject: note 91841 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-157641@lists.php.net to get a copy of this message
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()) ---- Server IP: 195.221.21.36 Probable Submitter: 86.202.133.223 ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- https://master.php.net/note/edit/91841 Del: integrated -- https://master.php.net/note/delete/91841/integrated Del: useless -- https://master.php.net/note/delete/91841/useless Del: bad code -- https://master.php.net/note/delete/91841/bad+code Del: spam -- https://master.php.net/note/delete/91841/spam Del: non-english -- https://master.php.net/note/delete/91841/non-english Del: in docs -- https://master.php.net/note/delete/91841/in+docs Del: other reasons-- https://master.php.net/note/delete/91841 Reject -- https://master.php.net/note/reject/91841 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157641) next »