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

From: Date: Tue, 27 Sep 2005 14:01:38 +0000
Subject: Re: best way to save program prefs to a file?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-223279@lists.php.net to get a copy of this message
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

« previous php.general (#223279) next »