I am trying this to test wether an XML documents gets created or not but its not working, Is there any problem in syntex?
function createFile()
{
// create new dom document
$xml = new DOMDocument();
// these lines would create a nicely indented XML file
$xml->preserveWhiteSpace = false;
$xml->formatOutput = true;
// create a root element
$root = $xml->createElement("phonebook");
// add root to DOM document root
$xml->appendChild($root);
// save dom document to an xml file
$xml->save('out.xml');
}
I don’t know from where you exactly getting only this much code….
Your code syntax are correct and everything is fine, to get the output you need to create the file.
Add this to end of your file:-
You will see an output file with something like this:-