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: 2020-12-23 15:52 UTC
From: michaelduff2 at yahoo dot com Assigned:
Status: Suspended 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:
5 + 1 = ?
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

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-23 15:52 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2020-12-23 15:52 UTC] cmb@php.net
This feature request likely requires an RFC[1], so please start
that process.  For the time being, I'm suspending this ticket.

[1] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC