Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 23106 программистов и 1587 роботов. Сейчас ищут 1796 программистов ...

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.

Available Options
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

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware