2010-08-11 42 views
0

我有这个PHP文件:的Apache/PHP是服务于错误的内容类型

<?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> 

我希望它返回一个头。

它所做的不过是回到Content-Type:text/html

你可以看看,结果在这里:http://knox.orgapage.de/hello.php

如果我改变文件扩展到.XML(当然没有的PHP标签),一切正常。然而,我想用PHP动态生成内容。

任何建议如何解决这个问题?我该如何让浏览器知道它应该将内容解释为XML?

回答

4

它也不输出任何文本。
我认为这是因为PHP端的一些错误
你必须参考错误日志并修复错误。

是的,就是这样

<?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> 

将解决您的问题

+0

不错!谢谢。这样可行。 – JochenJung 2010-08-11 06:20:58

相关问题