dongxiejie9387
dongxiejie9387
2010-07-06 10:07

为什么浏览器试图下载我的PHP脚本文件?

  • 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/vnd.google-earth.kml');

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

Could that be possible cause of this?

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

7条回答

为你推荐