NYCPHP Meetup

NYPHP.org

[nycphp-talk] define variables versus assigned variables

David Mintz vtbludgeon at gmail.com
Tue Jan 5 09:50:21 EST 2010


On Sun, Jan 3, 2010 at 7:48 AM, <webmaster at vbplusme.com> wrote:

> Hello Eddie,
>
> Sunday, January 3, 2010, 3:25:22 PM, you wrote:
>
> > The primary difference between a variable and a constant is
> > mutability.  If your database authorization details are not going to
> > change, make them constants.  If your database details DO change
> > throughout the execution of a script, make them variables.  In regards
> > to the performance of constants in PHP, that's an incredibly minor
> > improvement (a microoptimization, really) and it's my opinion that you
> > ought to be writing software to be good code and not have to hack
> > around considerations like how many microseconds your database
> > username declaration takes.[...]
>

Though you might also want to consider loading the values from a config
file, which is easy to change when you move your app from place to place,
e.g., from development to production.

Zend_Config makes this especially easy. You set a default configuration
environment and define other flavors that inherit from it.
http://framework.zend.com/manual/en/zend.config.html

-- 
Support real health care reform:
http://phimg.org/

--
David Mintz
http://davidmintz.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20100105/dc03a8ce/attachment.html>


More information about the talk mailing list