Re: Are constants more efficient than variables that never change?

From: Date: Wed, 16 May 2001 01:55:33 +0000
Subject: Re: Are constants more efficient than variables that never change?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-52971@lists.php.net to get a copy of this message
Ok, I'm only wondering this because I'm tryin to decrease the load time significantly because each page has to go through a lot of stuff before they're loaded and with the volume of hits it gets, i need anything to help out - Noah "CC Zona" <cczona@nospam.invalid> wrote in message news:9dsm85$kgl$1@toye.p.sourceforge.net... > In article <9dsknt$fb1$1@toye.p.sourceforge.net>, > noahsw@cyberdude.com ("Noah Spitzer-Williams") wrote: > > > So my question is should i just do: > > > > define("myvar", 3); > > > > OR: > > > > $myvar = 3; > > > > does defining it make that much of a difference (if i have several of these > > variables that could be defined instead). > > I'm not sure whether there's a significant difference in memory usage, but > IMO the difference in scoping rules is a significant consideration. > Constants carry over into functions local scope, while variables must be > explicitely passed or declared as global in order to become available in a > function's local scope. Which one you consider to be the "convenience" and > which you consider the "nuisance" is in the eye of the beholder <g>, but > IMO either way it's a very handy/exploitable distinction which you can use > to speed up development/debugging time. > > -- > CC > > -- > 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 (#52971) next »