note 64831 added to function.eval
| From: | nvdberge at yahoo dot com | Date: | Fri, 21 Apr 2006 13:07:57 +0000 |
| Subject: | note 64831 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-108920@lists.php.net to get a copy of this message | ||
This is a simple example of a string converted to a boolean using eval(). This can be useful when
you get a value from the database (as a string).
<?php
$string = "true";
$bool = eval("return ".$string.";");
if ($bool === true)
echo "boolean is true";
else
echo "boolean is not true";
?>
----
Server IP: 194.109.193.119
Probable Submitter: 82.204.13.196
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- http://master.php.net/note/edit/64831
Del: integrated -- http://master.php.net/note/delete/64831/integrated
Del: useless -- http://master.php.net/note/delete/64831/useless
Del: bad code -- http://master.php.net/note/delete/64831/bad+code
Del: spam -- http://master.php.net/note/delete/64831/spam
Del: non-english -- http://master.php.net/note/delete/64831/non-english
Del: in docs -- http://master.php.net/note/delete/64831/in+docs
Del: other reasons-- http://master.php.net/note/delete/64831
Reject -- http://master.php.net/note/reject/64831
Search -- http://master.php.net/manage/user-notes.php