Re: Globals

From: Date: Sun, 20 Aug 2000 08:54:09 +0000
Subject: Re: Globals
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-12637@lists.php.net to get a copy of this message
You may also want to look into using static variables, or possibly DEFINES. -jeremy brand _______________________________________________________________________ GnuPG Fingerprint: 9F5E 95E0 1CC2 E054 84EA 6099 8ACD 9DBA D2C0 5EA9 _ http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more __ On Sun, 20 Aug 2000, David Schultz wrote: > Date: Sun, 20 Aug 2000 01:01:17 -0700 > From: David Schultz <vvortex1@home.com> > To: php-general@lists.php.net > Subject: [PHP] Globals > > I have some functions which are used in several scripts, so I have them in > includes. However, the functions need at least five global variables each. I > don't want any flames about using global variables--- Apache variables are > global and there's nothing I can do about it, variables relating to the user > authentication include file are global and it would be stupid to do anything > else, and others are so extensively used in the main body of the script that > it would be pointless to commit changes to the database just to have the > functions read them back. Passing them as arguments is also a bit silly > because there are rather a lot of them, and most of them don't change--- > those that do are parameters already. > > Currently, I simply declare all of the globals at the start of the function, > and my nomenclature is such that there shouldn't be any confusion between > local variables. However, it looks very sloppy. Should I a) rewrite > everything to use the GLOBALS array, b) split each function into one include > file, and just include the file whenever I mean to invoke the "function" or > c) do something else creative that I haven't thought of yet. Are there any > performance reasons that I might choose one over the other? Thanks in > advance. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#12637) next »