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

Your name:

Reply:


Posted by "A.J. Brown" on 09/27/05 17:35

Are you wanting the preferences to be real-time changeable? For example,
user preferences that can be modified then saved? If so, just store them in
an array, then serialize the array and save it to a file. Read the file at
every page load.

[code]

//save the settings
$user_settings['setting1'] = 'foo';
$user_settings['setting2'] = 'bar';

$fh = fopen('user_settings.dat');
$serialized = serialize($user_settings);
fwrite ($fh, $serialized, strlen($serialized));
fclose($fh);

//reload the settings
$user_settings = unserialize(file_get_contents('user_settings.dat'));


[/code]


Hope this helps.

--

Sincerely,

A.J. Brown



"Jay Blanchard" <jay.blanchard@THERMON.com> wrote in message
news:0CEC8258A6E4D611BE5400306E1CC92708D47293@smtmb.tmc.local...
> [snip]
> 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?
> [/snip]
>
> Open a new file, save stuff to it, close the file.
> Include the file where you need the prefs.
>
> http://www.php.net/fopen
> http://www.php.net/explode

[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

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