php.net |  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
Votes:11
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
 [2001-11-08 15:30 UTC] sbarnum at pointsystems dot com
I'm trying to validate some dynamically generated PHP code using eval()
set_error_handler('eval_error');
eval($php_code);
restore_error_handler();

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

Patches

Pull Requests

History

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 http://bugs.php.net/bug.php?id=17731

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] jani@php.net
-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] jani@php.net
-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] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2013-10-27 15:42 UTC] krakjoe@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC