Re: Re: Config files: what is best? (was: Re: [PHP] XML... Useful or another layer of complexity?)
| From: | Richard Quadling | Date: | Mon, 04 Apr 2011 09:59:00 +0000 |
| Subject: | Re: Re: Config files: what is best? (was: Re: [PHP] XML... Useful or another layer of complexity?) | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-312235@lists.php.net to get a copy of this message | ||
On 3 April 2011 21:38, Peter Lind <peter.e.lind@gmail.com> wrote:
> On 3 April 2011 22:35, Andre Polykanine <andre@oire.org> 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