PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Thomas Schmidt  >  Configuration reader and writer  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example file
Class: Configuration reader and writer
Read and write configuration text files
Author: By
Last change:
Date: 3 years ago
Size: 1,312 bytes
 

Contents

Class file image Download
<?
include("config.class.php");
 
$conf = new configuration;
 
$creationarray = array(
    array(
"type" => "comment", "name" => "", "value" => "Class build by Thomas Schmidt"), // This is an out-marked comment
   
array("type" => "empty", "name" => "", "value" => ""), // This is an emtpy line
   
array("type" => "setting", "name" => "ipadress", "value" => "127.0.0.1"), // This is a new setting
   
array("type" => "setting", "name" => "something", "value" => "true"),
);

$filename = "./filename.whatever";

$conf->writeconfig($filename, $creationarray); // Let's write the new file.

// Now it's time to change the config again.


$changearray = array(
    array(
"type" => "setting", "name" => "ipadress", "value" => "127.0.0.2"), // Let's change the ip adress
   
array("type" => "empty", "name" => "", "value" => ""), // Here's an empty line again at the end of the current file
   
array("type" => "comment", "name" => "", "value" => "Info: Neuer Value kommt hinzu :D"), // The next comment and ...
   
array("type" => "setting", "name" => "something_else", "value" => "false"), // a new setting shall be written.
);


$conf->writeconfig($filename, $changearray); // Change the file again

$config = $conf->readconfig($filename); // Read the settings - they are set in an array

print_r($config);
?>