PHP Classes
elePHPant
Icontem

PHP INI Class: Handle ini files and defaults

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2002-10-09 (14 years ago) RSS 2.0 feedNot enough user ratingsTotal: 2,409 All time: 1,555 This week: 946Up
Version License PHP version Categories
ini 1.0GNU General Publi...3Files and Folders, Parsers
Description Author

This class can read and parse INI files without using the parse_ini function.

It can open a given INI file and use regular expressions to extract the sections and values of properties defined in the configuration file.

The class can return the values of settings by name and section, or default values in case the settings are missing from the INI file.

Picture of Daniel Jänecke
Name: Daniel Jänecke <contact>
Classes: 2 packages by
Country: Liechtenstein

Details
ini.class.php

Version:     0.2 beta
Author:      Daniel Jaenecke <jaenecke@gmx.li>
PHP-Version: 4.2.3

Beware:
    This class is still beta. It should work fine when used as described below,
    butt here is no real error-handling yet nor hast here been much testing. So
    just be aware...

Purpose:
    Handle ini files :)

You can simply use this class to read an ini-file and return as an array - just
like parse_ini_file() does.
But his class can do some more...

Features:

    Handling default values
        You can load an additional defaults-file. Whenever you request an 
        ini-value which is not set but available from the defaults it will be 
        returned from there.

    Parsing of constants
        When using parse_ini_file() any value which represents a defined 
        constants name is replaced by the according value - which can be quite 
        useful, but is not always desired - and it cannot be turned off. 
    
        the ini.class offers this as a feature. You can control the replacement 
        by setting $parse_constants to TRUE/FALSE. Also, any value enclosed in 
        single or double quotes will not be replaced by a constant's value, 
        ignoring the setting of $parse_constants.
    
Syntax of ini/default files
    
    Comments
        Comments start with # or //. Anything to the end of line is ignored.
        Empty lines are also ignored.
    
    Key-/Value pairs
        Assigning values to a key is done like

            key = value
    
        to prevent value from being replaced by the value of a constant with
        the same name you can enclose value in single or double quotes:
        
            key = "value"
            key = 'value'
        
        Since quotes are removed if they enclose a value you have to use them 
        twice if they are desired, like 
        
            key = ""value""
    
    Sections
        Sections are enclosed into [ ]. Any section containing no key/value-pair
        is ignored.
        
    Anything else
        Any line not matching one of the patterns for section or key/value will
        be ignored. There is no error-handling yet!
  Files folder image Files  
File Role Description
Accessible without login Plain text file example Doc. small examples
Plain text file ini.class.php Class class definition
Accessible without login Plain text file properties.txt Doc. Methods and properties of ini.class.php
Accessible without login Plain text file README Doc. readme

 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,409
This week:0
All time:1,555
This week:946Up