Page 1 of 1

change value in a configuration file

Posted: Mon Feb 13, 2012 5:50 pm
by srdva59
hi,
i have a configuration file with this content for example:

test = "100";
teste2 = "300";

now need change the test from 100 to 300,
i just want use something like this: function ( "test" , 300 );
how can i do that?
thanks for help

Re: change value in a configuration file

Posted: Mon Feb 13, 2012 6:40 pm
by Christopher

Code: Select all

class Config {
protected $data = array();

public function __construct($data) {
    $this->data = $data;
}

public function set($name, $value) {
    $this->data[$name] = $value;
}

public function get($name) {
    return isset($this->data[$name]) ? $this->data[$name] : null;
}

}

$config = new Config(array('test'=>"100", 'teste2'=>"300"));
echo $config->get('test');
$config->set('test', '300');
echo $config->get('test');