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 Description
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

require_once 'Config.php';

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

$dbsect $root->createSection('database');

//this is a nested section
$subsect $dbsect->createSection('settings');

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

Generated file

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

$conf['database']['host'] = '';
$conf['database']['name'] = 'demo-db';
$conf['database']['settings']['charset'] = 'utf-8';
$conf['database']['settings']['reconnect'] = true;
IniFile (Previous) PHPConstants (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.