0

I have a php that generates a XML file. It begins with the following code:

header("Content-Type: text/xml; charset=UTF-8");
header('Content-Disposition: attachment; filename="FileName.xml"');

// Outputs a lot of XML

When I'm running PHP 5.2 it works fine, but on 5.3 an empty file is generated. Any ideas about why it's empty?

2
  • 4
    Post the complete code, I doubt if headers have anything special to do in this scenario.
    – Kumar
    Aug 5, 2011 at 13:01
  • did you try this on same sever setup? I would say it is probably not caused by difference in php version, rather something else. for instance try this and see if it works. ob_start(); at the very beginning before header. and at the very end of the file; $xml=ob_get_contents(); ob_end_clean(); echo $xml; Aug 5, 2011 at 13:03

1 Answer 1

1

this sounds like it could be related to short open tags functionality: <? vs <?php?

make sure you have short open tags disabled in your php.ini. if you need it activated, there's a workaround: for <?xml tag, wrap it in a string and echo it, so it will not be interpreted as the start of a php block by php

echo '<?xml … >';
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.