Jump to content

Ocs-server/Gfx4/Editing config files programmatically

From KDE Community Wiki
Revision as of 15:48, 5 May 2016 by Snizzo (talk | contribs) (Created page with "GFX provides a handy class that lets you edit config files programmatically to create easy admin modes and settings managers. All changes are made in ram before being saved t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

GFX provides a handy class that lets you edit config files programmatically to create easy admin modes and settings managers.

All changes are made in ram before being saved to disk with the save() method. Remember to call save(), or your changes will be lost at the end of object's life.

<?php
//constructor, $namefile can be empty
$config = new EConfigFile($namefile);
//set $key with $value
$config->set($key, $value);
//get $value associated to $key
$config->get($key);
//delete $key from config file
$config->del($key);
//apply modifications, save
$config->save();
?>