Reply to Re: [PHP] best way to save program prefs to a file?

Your name:

Reply:


Posted by Torgny Bjers on 09/27/05 17:01

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация