php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40339 new superglobal...
Submitted: 2007-02-03 03:50 UTC Modified: 2010-12-22 13:23 UTC
Votes:3
Avg. Score:2.0 ± 1.4
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: randallgirard at hotmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.0 OS: Windows / Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: randallgirard at hotmail dot com
New email:
PHP Version: OS:

 

 [2007-02-03 03:50 UTC] randallgirard at hotmail dot com
Description:
------------
Just as there is a $GLOBALS var pointing to the global scope, there should also be a $SCOPE or $LOCALS var pointing to the current local, usually function/method scope. This would add alot of coding potential, and should be included in the language because of misc features like variable variables which appear to utilize the local, then global scope if the var is not defined locally. It would also greatly aid in debugging, as you could quickly and easily dump all var's in the scope... And, I'm sure others could find many more uses for such a feature.

If such a feature allready exists, I'm sorry for my ignorance and I would greatly appreciate feedback informing me of how a local scope array could be accessed. THANKS!!


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-25 13:11 UTC] michael at chunkycow dot com dot au
This sounds totally bogus, I do not know of any other language that comes close to providing such a thing.
If you have trouble keeping track of the scoping of a given variable it's an implementation/programmer problem not a language one.
 [2009-01-20 09:56 UTC] a at b dot c dot de
I can't even make out what "misc features like variable variables which appear to utilize the local, then global scope if the var is not defined locally" is even referring to - I've never seen global variables leaking into the local scope without my asking for them.

If your coding is so borked that you don't even know what variables you have or not you can get a list of local variables by taking get_defined_vars() and subtracting $GLOBALS.
 [2010-12-22 13:23 UTC] johannes@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2010-12-22 13:23 UTC] johannes@php.net
You can use get_defined_vars(). Adding a magic variable is quite expensive,even when not used. And most people would never use it.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 18:01:33 2025 UTC