Justin French <[EMAIL PROTECTED]> has the same first name as me :)
and wrote:

> 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!!!

You could do it by making each variable an array with a key of 'local' and
'live' like this:

<?
$cfgAdminEmail = array("local" => "localaddress", "live" => "liveaddress");
etc.
etc.
?>

Then you could set something like $server to "local" or "live"
and refer to the var's by $cfgAdminEmail[$server];

Justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to