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

From: Date: Tue, 22 Oct 2002 19:41:06 +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-120973@lists.php.net to get a copy of this message
One way or the other, you're going to have to do something on every page. Personally, I use constants in a config file for something like this, and require_once the config file on every page. Another possible way would be to set your default settings in a session when a visitor first comes to the site, but this would just be extra work since you would also have to check if the variables are set, and if not set them, on each page. define ( "VarName", "VarValue" ); echo ( VarName ); This will even be available inside of functions without having to use the global keyword. The only drawback is that you will not be able to change the value of VarName on that page. Monty wrote:
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? Thanks!!


« previous php.general (#120973) next »