php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31339 Strange parser errors with eval
Submitted: 2004-12-30 00:20 UTC Modified: 2004-12-30 11:10 UTC
From: bart at mediawave dot nl Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.3 OS: WinXP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bart at mediawave dot nl
New email:
PHP Version: OS:

 

 [2004-12-30 00:20 UTC] bart at mediawave dot nl
Description:
------------
My script depends heavily on eval and since I upgraded to PHP 5.0.3 everything completely broke down. (I think I was using 5.0.0 before I upgraded) (And yes, I know, Using eval() is a very dirty thing to do ;) )

After hours and hours of pinpointing I found out that things go wrong when code is running through eval(). The same code running directly (without eval()) runs flawlessly. It looks like there are some parsing problems with eval() or something.

I'm also getting weird ODBC problems as soon as correctly working code runs through eval():

Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver]Invalid use of null pointer , SQL state S1009 in SQLExecDirect in D:\php\includes\sp6\modules\bwceval.php(33) : eval()'d code on line 24 

I got the above warning out of the command line version of PHP since IIS only gave me a:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

Anywayz. I've got some very simple code that reproduces my problem:

Reproduce code:
---------------
<?php 

echo 'hello';

$myvar = 'Why did the chicken cross the road?';

$string = "

echo 'hello';

$myvar = 'Why did the chicken cross the road?';
  
";

eval ($string);

?>

Expected result:
----------------
hellohello

Actual result:
--------------
hello
Parse error: syntax error, unexpected T_STRING in D:\Inetpub\wwwroot\test4.php(24) : eval()'d code on line 5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-30 10:58 UTC] derick@php.net
You need to escape use of vars inside your eval'ed string otherwise they are substituted with the value. Your eval'ed code looks like something like:

echo "hello";

'Why did the chicken cross the road?' = 'Why did the chicken cross the road?'

which obviously is wrong
 [2004-12-30 11:09 UTC] bart at mediawave dot nl
damned... Now I feel really stupid...
 [2004-12-30 11:10 UTC] bart at mediawave dot nl
whoops... bag to Bogus again...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 15:01:33 2024 UTC