JochenJung
JochenJung

Reputation: 7213

Apache / PHP is serving the wrong content type

I have this PHP file:

<?php
header('Content-type: text/xml; charset=UTF-8');
?><?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="hello world example" /> 
  <Content type="html">
     <![CDATA[ 
       Hello, world!
     ]]>
  </Content> 
</Module>

I would expect it to return a Content-type:text/xml header.

What it does however is to return Content-Type:text/html

You can have a look at the result over here: http://knox.orgapage.de/hello.php

If I change the file extention to .xml (without the PHP tags of course), everything works fine. I however want to generate the content dynamicaly with PHP.

Any suggestions how to solve this? How can I let the browser know, that it should interpret the content as XML?

Upvotes: 0

Views: 2028

Answers (1)

Your Common Sense
Your Common Sense

Reputation: 157981

it does not output any text as well.
I assume it is because of some error on the PHP side
You have to refer to error log and repair that error.

yeah that's it

<?php
header('Content-type: text/xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8" ?>';
?>

<Module>
  <ModulePrefs title="hello world example" /> 
  <Content type="html">
     <![CDATA[ 
       Hello, world!
     ]]>
  </Content> 
</Module>

will solve your problem

Upvotes: 4

Related Questions