I know that directly setting a variable in the scope of caller is probably not a good idea.
However, the PHP extract() function does exactly that! I would like to write my own version of extract() but cannot figure out how to actually go about setting the variables in the caller. Any ideas?
The closest I have come is modifying the caller’s args using debug_backtrace(), but this is not exactly the same thing…
I know that directly setting a variable in the scope of caller is probably
Share
You can’t modify local variables in a parent scope – the method which extract() uses is not exposed by PHP.
Also, what you get back from debug_stacktrace() isn’t magically linked to the real stack. You can’t modify it and hope your modifications are live!