Re: smarter way to write config file?

From: Date: Tue, 16 Apr 2002 07:26:03 +0000
Subject: Re: smarter way to write config file?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-93136@lists.php.net to get a copy of this message
what about something like this: $cfgAdminEmail = ( $local ) ? "justin@indent.com.au" : "webmaster@foo.com"; $cfgReportErrors = ( $local ) ? 1 : 0; $cfgSendMail = ( $local ) ? 0 : 1; Hope this helps --Scott ----- Original Message ----- From: "Justin French" <justin@indent.com.au> To: "php" <php-general@lists.php.net> Sent: Tuesday, April 16, 2002 6:58 AM Subject: [PHP] smarter way to write config file? > Hi all, > > Currently i've got a config file for each website, and I split it into > essentially two config files, based on the server name, so that I can have 1 > file for both my local server and the live server. > > something like: > > <? > > if($local) > { > $cfgAdminEmail = "justin@indent.com.au"; > $cfgReportErrors = 1; > $cfgSendMail = 0; > } > else > { > $cfgAdminEmail = "webmaster@foo.com"; > $cfgReportErrors = 0; > $cfgSendMail = 1; > } > > ?> > > But of course, there's more like 20 config elements. The small problem I'm > having is making sure that I keep both halves (live and local) the same (but > with different settings). > > > What i was hoping was that there may be a way of writing the config once, > and having it work in both situations, perhaps with a switch, or with some > other language construct I have no idea about: > > I know this isn't the answer, but I was hoping for something like: > > <? > $cfgAdminEmail = "justin@indent.com.au|webmaster@foo.com"; > $cfgReportErrors = "1|0; > $cfgSendMail = "0|1"; > ?> > > Where both the options "local|live" were declared in one hit. > > > Whatever solution there is (arrays? switches?) it has to be easy to > maintain, otherwise it's a step backwards I guess. > > > Any suggestions appreciated, or pointers to stuff in the manual i've never > heard of!!! > > > Justin French > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#93136) next »