PHP Classes

File: test_config.php

Recommend this page to a friend!
  Classes of Guilherme Blanco   pConfig   test_config.php   Download  
File: test_config.php
Role: Example script
Content type: text/plain
Description: First Test
Class: pConfig
Manage hierarchical configuration files
Author: By
Last change: Editted hasChild => hasChilds (as posted by Jack)
Changed output language to English.
Date: 19 years ago
Size: 1,053 bytes
 

Contents

Class file image Download
<?php

require_once "class.pConfig.php";

// Checks if Module pConfig is loaded
if (defined("MOD_PCONFIG"))
    echo
"<h1>pConfig Module Loaded</h1>\n";

$config = new pConfig;

// Creating Childs with custom values
$config->add("child1");
$config->add("child2", "value");
$config->add("child3", array(1 => "value1", "item2" => 200));

$config->add("child1/sub-child1");
$config->comment("child1/sub-child1", "Testing comments");
$config->add("child1/sub-child2", 200);

$config->add("child4", "value");

// Testing get
echo $config->get("child2")."<br />";
echo
$config->get("child1")."<br />";

// Testing remove
$config->remove("child2");

// Retrieving useful information
echo "Child4 ".(($config->isRoot("child4")) ? "is" : "isn't")." root<br />";
echo
"Child2 ".(($config->hasChilds("child2")) ? "has" : "doesn't have")." childs<br />";
echo
"Child1 ".(($config->hasValue("child1")) ? "has" : "doesn't have")." value<br />";

// Writting configuration into file
$config->write("config_generated.ini.php");

?>