php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60072 eval parameter must not begin with <?php
Submitted: 2011-10-16 20:28 UTC Modified: 2011-12-03 06:26 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mkllnk at web dot de Assigned:
Status: Wont fix Package: Documentation problem
PHP Version: 5.3.8 OS: Debian Squeeze
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-10-16 20:28 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-03 06:26 UTC] frozenfire@php.net
-Status: Open +Status: Wont fix
 [2011-12-03 06:26 UTC] 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-12-03 10:55 UTC] mkllnk at web dot de
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?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 05:01:33 2024 UTC