Doc #60072 [Com]: eval parameter must not begin with <?php
| From: | mkllnk at web dot de | Date: | Sat, 03 Dec 2011 10:55:24 +0000 |
| Subject: | Doc #60072 [Com]: eval parameter must not begin with <?php | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7515@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60072&edit=1
ID: 60072
Comment by: mkllnk at web dot de
Reported by: mkllnk at web dot de
Summary: eval parameter must not begin with <?php
Status: Wont fix
Type: Documentation Problem
Package: Documentation problem
Operating System: Debian Squeeze
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
You are not right.
If I include another file via "include 'example.php';", then this file has to
begin with "<?php". Otherwise the text will be raw output text.
If I put the content of example.php in the eval function like in my description,
then a parse error occurs. The example (Test script) contains only one PHP opening
tag.
So what is wrong? The eval funtion or the documentation?
Previous Comments:
------------------------------------------------------------------------
[2011-12-03 06:26:07] frozenfire@php.net
I don't think there's much confusion to be had about this. eval() essentially
acts as if you save the string to a file, then include() that file. It's
basically pasting that code into the current scope.
If one places an open tag after another open tag, they should expect an error.
That much should be somewhat evident.
------------------------------------------------------------------------
[2011-10-16 20:28:46] mkllnk at web dot de
Description:
------------
---
From manual page: http://www.php.net/function.eval#refsect1-function.eval-
parameters
---
The eval documentation says: "The code string to be evaluated. code_str does not
have to contain PHP Opening tags."
But the code string must not contain PHP Opening tags unless after a PHP Closing
tag.
Test script:
---------------
<?php
eval('<?php echo "hallo\n"; ?>');
?>
Expected result:
----------------
hallo
Actual result:
--------------
PHP Parse error: syntax error, unexpected '<' in /tmp/php/test.php(3) : eval()'d
code on line 1
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60072&edit=1