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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michaelduff2 at yahoo dot com
New email:
PHP Version: OS:

 

 [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: Sun Nov 19 01:31:42 2017 UTC