Thanks heaps Scott -- exactly what I was hoping for :)
Justin French
on 16/04/02 5:26 PM, Scott Houseman ([EMAIL PROTECTED]) wrote:
> what about something like this:
>
> $cfgAdminEmail = ( $local ) ? "[EMAIL PROTECTED]" : "[EMAIL PROTECTED]";
> $cfgReportErrors = ( $local ) ? 1 : 0;
> $cfgSendMail = ( $local ) ? 0 : 1;
>
> Hope this helps
>
> --Scott
> ----- Original Message -----
> From: "Justin French" <[EMAIL PROTECTED]>
> To: "php" <[EMAIL PROTECTED]>
> 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 = "[EMAIL PROTECTED]";
>> $cfgReportErrors = 1;
>> $cfgSendMail = 0;
>> }
>> else
>> {
>> $cfgAdminEmail = "[EMAIL PROTECTED]";
>> $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 = "[EMAIL PROTECTED]|[EMAIL PROTECTED]";
>> $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
>>
>>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php