#36758 [Bgs]: eval not behaving like in documantation
| From: | colder@php.net | Date: | Thu, 16 Mar 2006 15:10:51 +0000 |
| Subject: | #36758 [Bgs]: eval not behaving like in documantation | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969372397@lists.php.net to get a copy of this message | ||
ID: 36758
Updated by: colder@php.net
Reported By: khan dot shadow at gmail dot com
Status: Bogus
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
There are a lot of non-sense in your post:
1) variables don't have to be escaped inside single quotes, the
evaluated code will result to a parse error.
2) you can't use echo in a return context, because echo is a language
construct that doesn't behave like a function.
3) your eval() will always be evaluated as false : "As of PHP 4, eval()
returns NULL unless return is called in the evaluated code".
Previous Comments:
------------------------------------------------------------------------
[2006-03-16 12:12:39] mike@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Then don't use the echo statement.
------------------------------------------------------------------------
[2006-03-16 12:00:53] khan dot shadow at gmail dot com
Description:
------------
" In case of a parse error in the evaluated code, eval() returns FALSE.
In case of a fatal error in the evaluated code, the whole script exits."
Reproduce code:
---------------
$page = 'for(\$i=0;\$i<=2;\$i++){?>';
$page .= '<b>test code</b>';
$page .= '<? } ?>';
'
$cad = $page;
$cad = @eval($cad)==false ? echo $cad : ob_get_contents();
Expected result:
----------------
$cad should be $cad='<b>test code</b><b>test code</b><b>test
code</b>'
Actual result:
--------------
$cad is echod to the screen
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36758&edit=1