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


Class file image Download

require_once "class.pConfig.php";

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

$config = new pConfig;

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

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

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

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

// Testing remove

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

// Writting configuration into file