Here's my code:
public function write($txt){
$randID = rand();
$doc = new DOMDocument();
$doc->formatOutput = true;
$doc->load($this->fileName);
$b = $doc->createElement( "input");
$id = $doc->createElement( "id",$randID);
$b->appendChild($id);
$text = $doc->createElement( "text",$txt);
$b->appendChild( $text );
$doc->appendChild($b);
$doc->save($this->fileName);
}
Why does this code always overwrite the old file? Why doesn't it append to the end of the existing file? I'm new to XML with PHP :)
new DomDocument()rather than existing one withDomDocument::load()