note 54871 added to function.eval
| From: | GuruEvi at osu1 dot php dot net | Date: | Mon, 18 Jul 2005 15:27:59 +0000 |
| Subject: | note 54871 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92116@lists.php.net to get a copy of this message | ||
I had a problem when I tried to execute the following:
<?php
while ($row = mysql_fetch_assoc($result)) {
if($row['eval'] == "1") {
echo "<h2 id=\"" . $row['tag'] . "\">" .
$row['title'] . "</h2>" . wordwrap(eval("?>" .
$row['content'] . "<?php "),$width_wrap,"\n",0) .
"<p> </p>";
} else {
echo "<h2 id=\"" . $row['tag'] . "\">" .
$row['title'] . "</h2>" .
wordwrap($row['content'],$width_wrap,"\n",0) .
"<p> </p>";
};
};
?>
As the values came out it seemed like this:
eval = 0 >> outputs a correct $row['content']
eval = 1 >> value of eval("?>" . $row['content'] . "<?php
") appended to the previous $row['content'] (yes: in between the </h2> and
<p> tag) and $row['content'] was empty in the current iteration of the while
statement.
eval = 1 >> the same thing happened, the value was appended to the previous
$row['content'] which was empty at that time and the current iteration was empty
eval = 0 >> outputs a correct $row['content']
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54871
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54871&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54871&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54871&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54871&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54871&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54871&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54871&report=yes
Search -- http://master.php.net/manage/user-notes.php