I noticed this in the last project I did, and ignored it, but it is causing illegal XML this time.
If I try to view the following page in IE or Chrome, both say the XML is illegal
Code: Select all
<?php
require("TestSetupVars.php");
header("Content-type: text/xml");
echo "<?xml version='1.0'?>";
echo "<note>";
echo "<from>Jani</from>";
echo "<to>Tove</to>";
echo "<message>Remember me this weekend</message>";
echo "</note>";
?>
Code: Select all
<?php
$a="a";
?>
Include does the same thing.
It looks as though the require is inserting a single character before the start of the xml document in the response output.
Chrome actually shows me a character (it looks like a dot) before the <note> in view source, but IE does not
This is happening on both my local machine (php 5.2.6) and the remote host (php 5.2.11). I can't upgrade the remote php version, so any ideas for a workaround?
The code I've posted here is to illustrate - in reality I need to require to do something useful, and rather than echoing out XML directly, I am using the DomDocument object.