文档末尾的其他内容PHP和XML [英] Extra content at the end of the document PHP and XML

查看:78
本文介绍了文档末尾的其他内容PHP和XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用PHP生成XML文件时遇到一个奇怪的问题.问题在于,在源代码的末尾会出现一个奇怪的问号.我收到错误消息:文档末尾的其他内容"

I having a strange problem when I'm trying to produce an XML file with PHP. The problems is that, a strange question mark appears at the end of the source code. And I get the error: "Extra content at the end of the document"

我正在运行此脚本:

<?php
header("Content-Type: application/xml");
echo "<?xml version=\"1.0\"?>";
?>

<Module>
      <ModulePrefs title="Ngram Extractor"
        author="interedition team"
       description="Ngram Extractor"
        scrolling="true"/>
        <Content type="html">
        Test
        </Content>
</Module>​

打开这是一个浏览器时,出现状态错误,并且源代码如下所示.请注意最后的奇怪问号.

When I open this is a browser, I get the state error and the source code looks like this. Notice the strange question mark at the end.

 <?xml version="1.0"?>
<Module>
      <ModulePrefs title="Ngram Extractor"
        author="interedition team"
       description="Ngram Extractor"
        scrolling="true"/>
        <Content type="html">
        Test
        </Content>
</Module>?

请帮助.

推荐答案

文件末尾有零宽度空格字符-UTF-8代码E2 80 8B.它放置在</Module>之后.以十六进制模式查看您的文件. 此多余的字符会阻止您的浏览器将其识别为有效的XML,并且-根据使用的浏览器-显示为问号或根本不显示.

You have a zero width space character at the end of your file - UTF-8 code E2 80 8B. It is placed right after </Module>. Have a look at your file in hex mode. This extra character prevents your browser from recognizing this as valid XML and - depending on the browser in use - shows up as a question mark or does not show up at all.

删除多余的字符,您会没事的.

Remove that extra character and you will be fine.

这篇关于文档末尾的其他内容PHP和XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆