PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Kaloyan Kirilov  >  Mrasnika's configuration system  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: An example
Class: Mrasnika's configuration system
Store and retrieve settings from XML files
Author: By
Last change:
Date: 12 years ago
Size: 3,241 bytes


Class file image Download

// The only parameter the
// constructor needs, is the path
// to the configuration XML file.
// You cann't assign ot later -
// only on initiliazation.
$CONFIG = new Config("./config.xml");

// You can get the data from the
// configuration file using the
// Get() method. Its parameters
// are the configuration file
// elements (levels) to the
// element you desire to access.
$session_id = $CONFIG->Get(
printf("The <b>session id</b> for the <i>user sessions</i> is [%s] <br><br>", $session_id);

// The Get() mehod is case
// insensitive, and you shouldn't
// bother matching the cases.
$MQ_gpc = $CONFIG->Get(
printf("The <b>Magic_quotes_GPC</b> is %s <br><br>", $MQ_gpc);

// An example of accessing
// super-administrator accounts.
printf("The <b>Built-In Super-Administrator</b> <i>Alias</i> is [%s] <br><br>",

// An example fo accessing
// option-list settings, which will
// be returned as an array.
"Administrators <b>notification options</b> are:<br>";
while (list(
$key, $value) = each($NOTIFICATIONS)) {
" - <i>$key</i> = $value<br>";

// You can access them
// individially by their name.
printf("The <b>notification option</b> <i>if error occurs</i> is %s <br><br>",

// The Set() method is for
// modifing the elements of
// the configuration. The first
// paramter passed is the value
// itself, and the rest parameters
// are the path to the element (
// just like for the Get() method).
// If element's not found, the
// method returns false.

$CONFIG->Set( "1",
//1 is for ON or TRUE, and
    //0 is for OFF or FALSE

// You can use the @-operatior to
// silence the errors from the config
// class.

// You can get all of the element
// properties by using the Details()
// method. It uses the same paramters
// as the Get() method.
$debug_log = $CONFIG->Details(
"<b>Debug-Log</b> properties are:<br>";
while (list(
$key, $value) = each($debug_log)) {
" - <i>$key</i> = $value<br>";

// You can save the modifications you
// made using the Save() method. It
// will creates a backup copy with your
// old settings, and then save the new
// one.
// The first save you ever make will be
// named "your_config_name.xml~ORIGINAL",
// the ones you make afterwards will be
// "your_config_name.xml~BACKUP-current_date"
// The only paramter provided is an
// alias for the "account", that saves
// the new configuration