PHPArray

Parses PHP Array structures. Can read from a PHP Source file or from an in memory array. Due to technical limitations, this container does not parse blank lines or comments when reading from a configuration file, therefore any information contained within PHP comments will be lost.

Available Options
Option Data Type Default value Описание
name string conf The name to use for the root configuration variable, both when parsing and writing PHP source files.
useAttr boolean TRUE Controls whether attributes are parsed and saved.

Since config files containing php arrays are just included using the standard php methods, code comments and structure will be lost when saving.

Writing a PHPArray config file

<?php
require_once 'Config.php';

$conf = new Config();
$root $conf->getRoot();
$root->createComment('Demo config file with PHPArray container');
$root->createDirective('openLastFile'true);

$root->createBlank();
$dbsect $root->createSection('database');
$dbsect->createDirective('host''db-server.example.org');
$dbsect->createDirective('name''demo-db');

//this is a nested section
$subsect $dbsect->createSection('settings');
$subsect->createDirective('charset''utf-8');
$subsect->createDirective('reconnect'true);

$r $conf->writeConfig('php-array-write.txt''phparray');
if (
PEAR::isError($r)) {
    echo 
$r->getMessage() . "\n";
}
?>

Generated file

<?php
// Demo config file with PHPArray container
$conf['openLastFile'] = true;

$conf['database']['host'] = 'db-server.example.org';
$conf['database']['name'] = 'demo-db';
$conf['database']['settings']['charset'] = 'utf-8';
$conf['database']['settings']['reconnect'] = true;
?>
    Поддержать сайт на родительском проекте КГБ