2010-07-06 10:07


  • firefox
  • browser
  • php

Just a quick one - I wrote a php script recently that dynamically creates XML file using API DOM. So I'm using this at the beginning:

$dom = new DOMDocument('1.0', 'UTF-8');

And at the end it looks like this:

$server = $_SERVER['DOCUMENT_ROOT'];
$path_to_xml = "$server/project/file.xml"; 
file_put_contents($path_to_xml, $dom->saveXML());

It does everything I wanted but why browser is trying to download this php script instead of just run it? Please can someone help me with this. I'm pretty sure it's something easy. //-----------------------------------edited Thanks for all replies. Yes I'm sending custom headers because it's google maps kml file that I'm creating dynamically.

header('Content-type: application/');

// Creates the root KML element and appends it to the root document.
$node = $dom->createElementNS('', 'kml');
$parNode = $dom->appendChild($node);

Could that be possible cause of this?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享