Re: read/write ini file

From: Date: Tue, 15 Apr 2003 12:10:44 +0000
Subject: Re: read/write ini file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-143921@lists.php.net to get a copy of this message
John, et al -- ..and then John W. Holmes said... % % > hi there i am considering of using the db/ini file to store global % > settings % > which some values will get stored into constants , how can i possible % read % > write from the ini blocks like so % % Reading is easy, just use parse_ini_file(). Hey, cool. I like that even better than our current include()ing. If I parse multiple ini files, will a setting in the last one override a setting in the earlier ones, or do I need to parse in reverse because it keeps the first one it reads? [Yes, I know I should test it and see, but I don't even have some sample code written yet :-] % % Writing isn't that difficult, either. I wrote a simple class that'll % read and write ini files by replacing the % % Variable = value I'm not so worried about writing the values back out, but I haven't yet found a way to preserve the comments and layout. That is, a file like ... ; the path is where you walk path = /this/path:/that/path ; size is the finished size size = 640 ; i could go on all day about this part. really. ; i even tend to ramble. but comments are important! important = very ; oh, yeah -- now we continue done = finally ... will only give me $path $size $important $done and not any of the comments or even the order in which the settings are specified... Any hope of preserving that? % % Lines with text boxes and wrapping a form tag around them all. Let me % know if you'd like to see it. Love to :-) I'm working my way toward a config web page where users can change their stuff, and writing the comments back sure would be nice. [I suppose I could alternatively embed the comments in the web page script, but that doesn't help someone who is editing the ini file manually.] % % ---John W. Holmes... TIA & HAND :-D -- David T-G * There is too much animal courage in (play) davidtg@justpickone.org * society and not sufficient moral courage. (work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

« previous php.general (#143921) next »