Push a variable into global scope?

Posted by Spot on Stack Overflow See other posts from Stack Overflow or by Spot
Published on 2010-03-22T09:12:04Z Indexed on 2010/03/22 9:21 UTC
Read the original article Hit count: 206

Filed under:
|

We use instantiate and put system critical objects in $GLOBALS for easy access from anywhere (e.g. DB, Cache, User, etc.).

We use $GLOBALS so much that it would (yes, really) drop the amount of code quite a bit if I could reference it like $G = &$GLOBALS for a shorthand call.

The problem is that, per my experience and several hours of Googling, I have not found any construct in PHP which allows you to 'flag' a var as global, making $GLOBALS first class, and everything else second class.

Am I missing something? Is this possible?

© Stack Overflow or respective owner

Related posts about php

Related posts about global-variables