|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #13993 Allow catching parse errors in eval() with user defined error handler
Submitted: 2001-11-08 15:30 UTC Modified: 2013-10-27 15:42 UTC
Avg. Score:4.8 ± 0.4
Reproduced:11 of 11 (100.0%)
Same Version:3 (27.3%)
Same OS:3 (27.3%)
From: sbarnum at pointsystems dot com Assigned: krakjoe (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: * OS: *
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 !
Your email address:
Solve the problem:
23 - 2 = ?
Subscribe to this entry?

 [2001-11-08 15:30 UTC] sbarnum at pointsystems dot com
I'm trying to validate some dynamically generated PHP code using eval()

problem:  if $php_code contains a parse error, the error is not reported using the eval_error() function, but uses the generic error handler.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-10 21:11 UTC] ben at qubed dot co dot nz
I have the same problem - would be a very nice feature to be able to catch errors in eval statements.
 [2002-06-12 16:58 UTC] jukkaho at mail dot student dot oulu dot fi
I share your problem and I think I have solved it (for 4.2.1 tree).

My bad english explanation with a patch can be found at

Try it out and report any problems it can cause. Maybe we can get the fix in.
 [2003-07-10 20:13 UTC] brad at info-link dot net
Any chance this might be changed?  I'd like to catch the "call to undefined function" error without the script dying...  Unless there is some other way to verify that a bit of php code is syntactically valid during script execution?  The tokenizer exension doesn't seem to care about how the tokens are ordered...
 [2011-01-01 00:08 UTC]
-Package: Feature/Change Request +Package: Scripting Engine problem -Operating System: Redhat Linux 7.1 +Operating System: * -PHP Version: 4.0.6 +PHP Version: *
 [2011-01-01 00:09 UTC]
-Summary: eval() parse errors not using error_handler +Summary: Allow catching parse errors in eval() with user defined error handler
 [2013-10-27 15:42 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2013-10-27 15:42 UTC]
To bring some closure: while we are using the current error handling mechanisms there is no good way to satisfy this request.

For clarity, the user error handler is called for eval'd code, it is called for eval'd code in the same places it is called for pre-compiled normal code. 

It's not feasible to do more, closing the bug.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Feb 03 08:05:55 2023 UTC