News Feed
Sections




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

PHPit.net:
Creating a PHP Settings Class
June 20, 2006 @ 09:35:03

PHPit.net is back again today with yet another great tutorial. This time, they help you create a class to manage the settings for your application that not only supports plain-text, but INI, XML, and YAML formats as well.

A config.php or a settings.xml file is a very common thing for most PHP scripts, and it's usually where all the script settings (e.g. database information) are stored. The easiest way is to simply use a simple PHP script as a config file, but this may not be the best way, and it's certainly not the most user-friendly way.

In this tutorial we'll have a look at creating a Settings class which can handle any type of config format. I'll take you through the steps necessary to handle four different formats (PHP, INI, XML and YAML), but it's very easy to add more formats.

To start, they build the base class before quickly adding the get() and load() functions to pull in the external content. First on the list, they extend the base and make a pure PHP implementation holding the settings. Following that, they move on to the INI format, using PHP's parse_ini_file function to make it simple.

Last but not least, they venture into something a bit more complex - working with XML and the YAML formats to create this simple, handy tool.

0 comments voice your opinion now!
settings class tutorial ini text parse_ini_file xml yaml settings class tutorial ini text parse_ini_file xml yaml


blog comments powered by Disqus

Similar Posts

Stefan Mischook's Blog: Cannot load mysql extension error - Video Tutorial How To

Blue Parabola Blog: Installing phpUndercontrol on Debian Etch

Anna Filina's Blog: Symfony - subfolders for partials

GoodPHPTutorials.com: SQL Injections in PHP with MySQL

Hasin Hayder's Blog: RSA Encrypting and Decrypting data with Zend_Crypt_Rsa Library


Community Events





Don't see your event here?
Let us know!


laravel install podcast configure threedevsandamaybe release framework wordpress language list code unittest series developer introduction testing opinion interview refactor community

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework