Iniphile/PHP

PHP binding for the Iniphile library

Author: Roman Neuhauser
Contact: neuhauser@sigpipe.cz
Copyright: This document is in the public domain.

Contents

1   Introduction

Iniphile/PHP is a PHP [1] binding for the Iniphile [2] library.

2   Compatibility

Iniphile/PHP has been used, and is expected to work in the following environments:

PHP:5.3, 5.4
OS:FreeBSD 9, Windows XP, Vista, 7, 2003 Server, 2008 Server R2
Compiler:GCC 4.2, 4.3, 4.4, 4.5, VS 2008 Express

PHP versions prior to 5.3 are not supported.

3   Prerequisities

4   Reference

4.1   INI file syntax

See the INI file syntax [3] section in the Iniphile documentation.

4.2   class iniphile

class iniphile
{
    static iniphile from_string(string $syntax);
    static iniphile from_file(string $path);

    __construct(string $path);
    array  get(string $query, array  $default);
    bool   get(string $query, bool   $default);
    float  get(string $query, float  $default);
    int    get(string $query, int    $default);
    string get(string $query, string $default);
}

4.2.1   iniphile::from_string

iniphile::from_string takes a single argument, a string $syntax conforming to the INI file syntax [3]. Returns an iniphile instance. Throws iniphile_error if parsing failed.

4.2.2   iniphile::from_file

iniphile::from_file takes a single argument, a file $path. Returns an iniphile instance. Throws iniphile_error if $path doesn't exist or parsing failed.

4.2.3   iniphile::__construct

iniphile::__construct takes a single argument, a file $path. Upon successful completion, $path has been parsed. Throws iniphile_error if $path doesn't exist or parsing failed.

4.2.4   iniphile::get

iniphile::get takes two arguments, string $query, and $default which may be array, bool, float, int, or string (or an object with a public string __toString() method). iniphile::get returns a value of the same type as the second argument.

Throws iniphile_error if called with a wrong number of arguments or if the second argument isn't of one of the allowed types.

See the Iniphile documentation for a complete description of iniphile::get<T> [4].

5   Downloads

5.1   Repository

The latest source can be checked out from the Mercurial [5] repository [6].