Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matt Kaufman's Blog:
Writing Custom Config Files with PHP
Jul 29, 2005 @ 17:36:23

Via a post on a del.icio.us feed today, there's this new post over on Matt Kaufman's weblog today - Writing Custom Configuration Files with PHP.

I recently discovered a PHP function which allows you to write your own custom configuration files for your projects. The possibilities of which you can do with this range pretty far: Database connection information, website layout settings (colors, table widths), etc.

This function is called parse_ini_file, see the documentation on it here. Basically, you construct your configuration file in a format such as php.ini, and run this function on it, which will return all the values in an array.

Moving on, he gives some examples of how this handy little function can be used with standardized ini files to make for quick and easy parsing/using in your scripts. And, with the output a multi-dimensional array, there's even more flexibility built right in...

tagged:

Link:


Trending Topics: