Here is my code:
public function xmlExport(){
$xml = new \SimpleXMLElement('<xml/>');
for ($i = 1; $i <= 8; ++$i) {
$track = $xml->addChild('track');
$track->addChild('path', "تست ");
$track->addChild('title', "Track $i - Track Title");
}
Header('Content-type: text/xml');
print($xml->asXML());
}
When I run code above, it prints something in the current browser page. But I want to make a .xml
file of that which is downloadable .. Is doing that possible by PHP?
With the Content-Disposition: attachment
header, you can force the browser to download your 'file'.
<?php
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="file.xml"');
xmlExport();
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments