Edit report at https://bugs.php.net/bug.php?id=60364&edit=1
ID: 60364 Comment by: hanskrentel at yahoo dot de Reported by: zyss at mail dot zp dot ua Summary: Implement ability to recover from fatal errors in eval()'d code Status: Open Type: Feature/Change Request Package: *General Issues Operating System: All PHP Version: 5.3.8 Block user comment: N Private report: N New Comment: Why specific for eval and not include and/or overal? This could be solved more straight forward solved by making fatal errors an Exception in PHP, like suggested in #28331 (which names eval in a comment as a use-case). Previous Comments: ------------------------------------------------------------------------ [2011-11-23 13:27:35] zyss at mail dot zp dot ua Description: ------------ Sometimes eval() is used as a way to execute PHP code within a shell (legal remote access for debugging purposes) or to execute code compiled to PHP from higher-level scripting language or the code stored in the database etc. The common problem is that a call of non-existing function (or object instantiation) results in termination of the whole script, not just eval'd code. I think that it's not correct in such cases. The obvious way to implement it would be adding flags to eval() function (as a second argument) one of which could indicate that eval() should not terminate the script but just return an error or raise an exception. Such flags could be: EVAL_FATAL_DIE // current behavior EVAL_FATAL_ERROR // return FALSE EVAL_FATAL_EXCEPTION // raise an exception of a predefined class (e.g. EvalException) Test script: --------------- try { eval('non_existing_function()', EVAL_FATAL_EXCEPTION); } catch (EvalException $e) { Logger::log('Error in eval\'d code', $e); } Expected result: ---------------- Exception being logged and script continued its execution. Actual result: -------------- Fatal error: Call to undefined function non_existing_function() in ... : eval()'d code(1) on line 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60364&edit=1