[development] Convention for accessing global variables

Nancy Wichmann nan_wich at bellsouth.net
Wed Dec 9 22:13:49 UTC 2009


Brian Vuyk wrote:
> two ways to access global variables
As far as I am concerned it comes down to how often the global variable is
to be accessed. Execution speed is not the only speed to worry about here.
Code loading speed is also important, and disk access is pretty slow (by
computer standards). So, if the global is to be accessed only once, it is
probably going to be more compact to use the $_GLOBAL form. If it is going
to be accessed many times (as $user often is), then I would use the "global"
form.

And, to me, that should be the standard.

Too often we focus more on the look of the code and not enough on its speeds
(both execution and loading). With the efforts that were begun in D6 and
further refined in D7, it would appear that the core developers are also
concerned with loading speed.


Nancy E. Wichmann, PMP 
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King,
Jr.



More information about the development mailing list