I want to be able to store website configuration without the use of mysql. I also want the user to be able to change this information from a web page. What's the best methods to do so?
4 Answers
Valuable options are a SQLite database, or just a PHP file containing a serialized array if you want a really simple option:
// reading configuration
$config = unserialize(file_get_contents('config'));
// storing configuration
file_put_contents('config', serialize($config));
5 Comments
Storing a file is the easiest option. You could store it in plain text, XML, JSON, etc. You might want to try an ini file which can be read/written by PHP - in which case this answer should help.
Comments
I would use a .ini file format to store configuration. It's human readable in its raw format and fairly easy to parse via PHP (parse_ini_file). A point to note here is that PHP (strangely) doesn't support writing to ini files natively, but if you look at the manual page for parse_ini_file you can find an user submitted example of how do it.
Altough I have not used in PHP projects, YAML (Yet Another Markup Language) seems like a good format to store configuration info (it's pretty much the default config format for rails projects). You can use the syck pecl library to easily read and write stuff in the YAML format