Example for ini.class.php
I assume that those example files exist and that the class definition is already
available...
File: settings.ini
[global]
foo = bar
version = PHP_VERSION
-----[ EOF ]-----
File: defaults,ini
[global]
a_default = a_value
-----[ EOF ]-----
An example of retrieving the settings of an ini-file as associative array,
parsing constants is on:
<?
$my_ini = new ini;
$my_ini->parse_constants = FALSE;
$array = $my_ini->read_ini ( 'settings.ini', TRUE );
print_r ( $array );
?>
would result in:
Array
(
[global] => Array
(
[foo] => bar
[version] => PHP_VERSION
)
)
Note:
the same example with setting parse_constants to TRUE (deafult) would result
in PHP_VERSION being replaced by the actual version (e.g. 4.2.2)
--------------------------------------------------------------------------------
An example of working with an ini-file and an defaults-file
<?
$my_ini = new ini ( 'settings.ini', 'defaults.ini' );
$foo = $my_ini->get ( 'foo', 'global' );
print_r ( $foo );
$foo = $my_ini->get ( 'a_default', 'global' );
print_r ( $foo );
$foo = $my_inin->get ( 'not_available' );
print_r ( $foo );
?>
would result in:
bar
a_value
[NULL]
|