|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-12-20 03:46 UTC] hanskrentel at yahoo dot de
[2011-12-20 15:05 UTC] zyss at mail dot zp dot ua
[2015-06-12 17:50 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: cmb
[2015-06-12 17:50 UTC] cmb@php.net
[2015-06-12 18:03 UTC] zyss at mail dot zp dot ua
-Status: Feedback
+Status: Assigned
[2015-06-12 18:03 UTC] zyss at mail dot zp dot ua
[2015-06-13 12:33 UTC] cmb@php.net
-Status: Assigned
+Status: Closed
[2015-06-13 12:33 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 09:00:02 2025 UTC |
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