PHPConstants

Parses a set of PHP define() from a PHP source file. Comments are maintained by this container, although blank lines will be lost. There are no options for this container.

Writing a PHPConstants config file

<?php
require_once 'Config.php';

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

$root->createBlank();
//PHPConstants container does not support sections but puts them in the main
// namespace
$dbsect = $root->createSection('database');
$dbsect->createDirective('host', 'db-server.example.org');
$dbsect->createDirective('name', 'demo-db');

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

Generated file

<?php

/**
 *
 * AUTOMATICALLY GENERATED CODE - DO NOT EDIT BY HAND
 *
**/
// Demo config file with PHPArray container
define('OPENLASTFILE', true);


//
// database
//
define('HOST', 'db-server.example.org');
define('NAME', 'demo-db');

?>