Re: Best way to set global params for entire site??

From: Date: Tue, 22 Oct 2002 19:40:29 +0000
Subject: Re: Best way to set global params for entire site??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-120971@lists.php.net to get a copy of this message
> I'm building a site with PHP and most scripts need access to certain > site-wide global parameters, such as paths and default settings, etc. What's > the best way to load this information so that it's globally available to all > scripts? I have a func.php file that is included in all scripts - do I just > load them every time for each script in there? Or is there a more efficient > way of doing this with environment variables or some other way? Usual method is just a config.php file that defines all the variables. I like to use a $_CONF[] array to store all my values $_CONF['html'] = "http://www.mysite.com"; $_CONF['db_user'] = "whatever"; etc... Then, if you need these values in a function, you can just make $_CONF global and you've got them. Or you can get fancy and get a config file parser and do things like [section 1] html = mypage.something.com db_user = whatever etc... You could probably find one of those on phpclasses.org or hotscripts.com. ---John Holmes...

« previous php.general (#120971) next »