php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69459 Allow retrieving variable references from parent scope(s)
Submitted: 2015-04-15 09:01 UTC Modified: -
From: michaelduff2 at yahoo dot com Assigned:
Status: Open Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
38 - 5 = ?
Subscribe to this entry?

 
 [2015-04-15 09:01 UTC] michaelduff2 at yahoo dot com
Description:
------------
The 'include' construct, by design, inherits the scope where it is executed which is great for templates, however:

When wrapping 'include' in a function to provide augmented include() or require() functionality, there is, AFAIK, no way to retrieve references to all variables from the caller's scope so that they may be imported into the local scope and accessed by the included script.

To provide this functionality, I propose adding a 'vars' element to the array returned by debug_backtrace() and a DEBUG_BACKTRACE_PROVIDE_VARS to optionally enable this functionality.

Note that the resulting 'vars' arrays would be filled with references so that extract() can provide bidirectional access to those variables.

Unless this can't be reasonably accomplished, I am willing to implement the necessary changes myself; please inform me how to submit the code accordingly.

Thank you.


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Tue Dec 11 15:01:25 2018 UTC