Re: Re: Discussion of method -- config files
| From: | Al | Date: | Fri, 20 Jun 2008 15:32:37 +0000 |
| Subject: | Re: Re: Discussion of method -- config files | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275704@lists.php.net to get a copy of this message | ||
Not so Robert, here's how I typically handle such situations.
$reqdApplicFilesArray = array(// *Required application files and define() value
'regAdminSettings.db' => 'ADMIN_SETTINGS_FILE',
'regMemberData.db' => 'MEMBER_DATA_FILE',
'emailCellSettings.db' => 'EMAIL_CELL_SETTINGS_FILE',
);
foreach($reqdApplicFilesArray as $file => $defineContant)
{define($defineContant, $file);}
Robert Cummings wrote:
On Fri, 2008-06-20 at 08:07 -0400, Al wrote:I freely use defined constants for all fixed variables in my config file.I guess you have no fixed array values since constants don't support non-scalars. The nice thing about arrays is how they group related configuration entries together. Cheers, Rob.It insures they cannot be inadvertently reassigned by a function someplace and are available everywhere. define('MYSQL_HOST',"localhost"); tedd wrote:Hi gang: More of a question of method rather than of "right" or "wrong" -- of the two methods mentioned here, which way would be "better" and why? 1. Setting $GLOBALS one time as shown here. At 12:23 AM -0400 6/19/08, Robert Cummings wrote:And the variables are defined in config.php -------------- config.php -------------- <?php //Mysql vars $GLOBALS['mysql_host'] = "localhost"; $GLOBALS['mysql_user'] = "user@localhost"; $GLOBALS['mysql_pass'] = ""; ?>2. Or, setting variables as shown below and including them when needed? -------------- config.php -------------- <?php //Mysql vars $localhost = 'localhost'; $mysql_user = 'user@localhost'; $mysql_pass = ''; ?> Cheers, tedd