Re: Re: Config files: what is best? (was: Re: [PHP] XML... Useful or another layer of complexity?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3 April 2011 21:38, Peter Lind <peter.e.lind@xxxxxxxxx> wrote:
> On 3 April 2011 22:35, Andre Polykanine <andre@xxxxxxxx> wrote:
>> Hello Peter,
>>
>> Thanks a lot! And is there a way to set (write) custom values in files
>> other than php.ini? Sorry, didn't find such a function.
>>
>
> I haven't come across any, but then again, I haven't had the need so
> never looked much ... It would be rather easy to generate though
>
> Regards
> Peter
>
> --
> <hype>
> WWW: plphp.dk / plind.dk
> LinkedIn: plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: kafe15
> </hype>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

For a truly quick and dirty config, then just use PHP.

A similar mechanism is used by PhD - the PHP Documentation building tool.

<?php
// Create default config
$config = array('item1' => 'value1');

// Load the saved config.
$loadedConfig = include './config.inc';

// Merge configs.
$config = array_merge($config, $loadedConfig);

// Manipulate config.
$config['item1'] = 'value2';

// Save config.
file_put_contents('./config.inc', '<?php return ' .
var_export($config, true) .';');
?>



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux