smarter way to write config file?

From: Date: Tue, 16 Apr 2002 04:58:55 +0000
Subject: smarter way to write config file?
Groups: php.general 
Request: Send a blank email to php-general+get-93125@lists.php.net to get a copy of this message
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

« previous php.general (#93125) next »