Re: Globals

From: Date: Sun, 20 Aug 2000 09:29:20 +0000
Subject: Re: Globals
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-12638@lists.php.net to get a copy of this message
Good ideas, but for this particular purpose, that wouldn't work. The variables need to have scope outside of the function as well. Many of these variables are really constant--- they're extracted from the database and used extensively throughout all parts of the script. However, most of them are arrays created with mysql_fetch_array(). This is all very strange to me. I get a nagging feeling that it shouldn't be this way because I almost never used globals in C++, but on the other hand, I see no other way. Thanks for the suggestions. ----- Original Message ----- From: "jeremy brand" <jeremy@nirvani.net> To: "David Schultz" <vvortex1@home.com> Cc: <php-general@lists.php.net> Sent: Sunday, August 20, 2000 1:54 AM Subject: Re: [PHP] Globals > 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 (#12638) next »