note 117765 added to function.eval

From: Date: Wed, 05 Aug 2015 18:39:25 +0000
Subject: note 117765 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-203266@lists.php.net to get a copy of this message
Sharing a code which might be useful to someone. my_eval() is useful if - You don't want to introduce new variables like what eval() would do. - You just want to execute some calculations or some file/database retrieval and return the result. - By returning the result in an array, you can differentiate a FALSE between a parse error or a result returned by the $code. function my_eval($code) { $my_code = '$my_function = function () {' . $code . '}; return array($my_function());'; return eval($my_code); } ---- Server IP: 72.52.91.14 Probable Submitter: 175.156.55.245 ---- Manual Page -- http://php.net/manual/en/function.eval.php Edit -- https://master.php.net/note/edit/117765 Del: integrated -- https://master.php.net/note/delete/117765/integrated Del: useless -- https://master.php.net/note/delete/117765/useless Del: bad code -- https://master.php.net/note/delete/117765/bad+code Del: spam -- https://master.php.net/note/delete/117765/spam Del: non-english -- https://master.php.net/note/delete/117765/non-english Del: in docs -- https://master.php.net/note/delete/117765/in+docs Del: other reasons-- https://master.php.net/note/delete/117765 Reject -- https://master.php.net/note/reject/117765 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203266) next »