xml render and save data to a file
<?php
class UpdateConfig
{
const CONFIG_FILE = 'info.xml';
private $settingsFile;
public function __construct()
{
$this->settingsFile = simplexml_load_file($this::CONFIG_FILE);
}
public function setText($value){
$this->settingsFile->text[0] = $value;
return $this;
}
public function setDebug($value){
$this->settingsFile->debug[0] = $value;
return $this;
}
public function saveConfig()
{
$newFile = $this->settingsFile->asXML();
file_put_contents('info.xml',$newFile);
}
public function getText(){
return $this->settingsFile->text[0];
}
public function getDebug(){
return $this->settingsFile->debug[0];
}
}
$file = new UpdateConfig();
$file->setText(4)->setDebug(6)->saveConfig();
echo $file->getDebug();
echo PHP_EOL;
echo $file->getText();
echo PHP_EOL;