Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 17408 программистов и 1871 робот. Сейчас ищут 1785 программистов ...
GenericConf
Вернуться к: Available Containers
Generic configuration files. The equals, comment start and new line characters in the parser can be customised to match your preferred configuration format.
Option | Data Type | Default value | Description |
---|---|---|---|
comment | string | # | The character that signifies the start of a comment. |
equals | string | : | The character that separates keys from values. |
newline | string | \ | The character that signifies that a value continues across multiple lines. |
Writing a config file with custom options
<?php
require_once 'Config.php';
$conf = new Config();
$root = $conf->getRoot();
$root->createComment('Demo config file with GenericConf container');
$root->createDirective('openLastFile', true);
$root->createBlank();
//GenericConf does not support sections, but section contents are serialized
// into the main config namespace
$dbsect = $root->createSection('database');
$dbsect->createDirective('host', 'db-server.example.org');
$dbsect->createDirective('name', 'demo-db');
$r = $conf->writeConfig(
'generic-conf-write.txt',
'genericconf',
array(
'comment' => '#',
'equals' => '=>',
)
);
if (PEAR::isError($r)) {
echo $r->getMessage() . "\n";
}
?>
Generated file
#Demo config file with GenericConf container openLastFile=>1 host=>db-server.example.org name=>demo-db
Вернуться к: Available Containers