代码之家  ›  专栏  ›  技术社区  ›  JochenJung

Apache/PHP服务的内容类型错误

  •  0
  • JochenJung  · 技术社区  · 14 年前

    我有一个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/xml 标题。

    然而,它所做的是返回 Content-Type:text/html

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

    1 回复  |  直到 14 年前
        1
  •  4
  •   Your Common Sense    14 年前

    它也不输出任何文本。
    我想这是因为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>
    

    会解决你的问题