php代码变成了xml?

I'm trying to evaluate the contents of mapvar.php and saving it to a variable. This is the code:

<?php
$filename = strval(rand(0,99999999999)).'.svg';
$fp=fopen($filename, 'wb+');

ob_start();
include 'mapvar.php';
$output = ob_get_clean();
ob_flush();

file_put_contents($filename,$output);
?>

<form action="download.php" method="post">
    <input type="hidden" name="filename" value="<?php echo $filename ?>" />
    <input type="submit" value="dl" />
</form>
<?php fclose($fp); ?>

For some reason, when I open the file, this message shows up (in both Chrome and FF):

"This XML file does not appear to have any style information associated with it. The document tree is shown below."

...and then the evaluated html code.

It seems to be caused by the ob_start() stuff, why is this?

mapvar.php probably sends a Content-Type: image/svg+xml header or something like that. You can override it later:

$output = ob_get_clean();
ob_flush();
header('Content-Type: text/html');

Also, there’s no need to use fopen or fclose with file_put_contents.