change value in a configuration file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
srdva59
Forum Commoner
Posts: 77
Joined: Sun Feb 15, 2009 10:58 am

change value in a configuration file

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: change value in a configuration file

Post 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');
(#10850)
Post Reply