Closed datashaman closed 8 years ago
I was able to get my idea working with plain eval. See the code below:
function staticEval($_code) { static $_vars = []; extract($_vars); $_result = eval($_code); $_vars = get_defined_vars(); unset($_vars['_vars']); unset($_vars['_code']); unset($_vars['_result']); return $_result; } staticEval('$a = "hello world!";'); staticEval('echo "$a\n";');
Neat!
I was able to get my idea working with plain eval. See the code below: