|  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
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
14 + 11 = ?
Subscribe to this entry?

 [2011-10-16 20:28 UTC] mkllnk at web dot de
From manual page:

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 

Test script:
eval('<?php echo "hallo\n"; ?>');

Expected result:

Actual result:
PHP Parse error:  syntax error, unexpected '<' in /tmp/php/test.php(3) : eval()'d 
code on line 1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-03 06:26 UTC]
-Status: Open +Status: Wont fix
 [2011-12-03 06:26 UTC]
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 

So what is wrong? The eval funtion or the documentation?
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 00:01:31 2024 UTC