Re: best way to save program prefs to a file?

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

 



Chris wrote:
> I'd like to save some program preferences to a txt file where they can be 
> recalled and updated at a later time. Basically this will be a variable name 
> and a value. Can someone suggest a reference or method to best perform this 
> task?
> 
> Thanks
> Chris
> BTW: I do not want to use MySql. 

Write a regular Windows .ini file like:

; My INI-file (this is a comment line):
key = value
key2 = value2
; It even works with PHP constants (defines) in the ini file
key3 = E_ALL

Reading it in is simple, use parse_ini_file():
http://www.php.net/manual/en/function.parse-ini-file.php

You can also keep sections in the .ini file such as:

; a section name uses []
[section1]
key = value
[section2]
key = value

To write this down is easy, just do a foreach on your associative array
and write to a string that you then save into a file if you wish to
update the values here.

Warm Regards,
Torgny

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