Problems with strings containing

Posted on 16th Feb 2014 by admin

Hey all,

I have encountered something strange in a script. I am trying to write an XML header and then fill in the file:
Code: $xmlFile = "fetchableData.xml";
$fh = fopen($xmlFile, 'r+');

$housingData = updateHousingAndReturnXML();
$xmlData = '<?xml version="1.0" ?>'.$housingData;

// echo $xmlData;

fwrite($fh,$xmlData);
fclose($fh);
This code fills the file with the contents of $housingData, but <?xml version="1.0" ?> is not added. If I break up <? it will add it but then I get errors when parsing the XML.

Echoing the string also doesn't work with <?.

I guess what is happening is that the string is getting parsed by the PHP engine for some reason. Escaping <? doesn't work.

I am assuming I am missing something basic. But the manual doesn't say anything about <? being parsed in strings.

Help?

Thanks

Other forums