zoukankan      html  css  js  c++  java
  • error on line 1 at column 6: XML declaration allowed only at the start of the document

    This page contains the following errors:

    error on line 1 at column 6: XML declaration allowed only at the start of the document

    Below is a rendering of the page up to the first error.

    --------------------------------------------------------------------------------------------------

    今天调试接口的时候又发现了这个东西,在Google上找来几篇stackoverflow的帖子,总算是解决了。一般出现这种情况的时候

    首先应该注意的是在“Header('Content-type: text/xml');”前不要有其他输出,最好将“Header('Content-type: text/xml');”放在文件的最顶端;

    然后检查一下是不是真的像它说的那样在输出的第一行有空行;

    最后就是检查你的编码是不是BOM格式的,如果是的话,改成无BOM格式的试试。

    什么是BOM,其实我也不太明白,所以就百度了一下:

    UTF-8 BOM又叫UTF-8 签名,其实UTF-8 的BOM对UFT-8没有作用,是为了支援UTF-16,UTF-32才加上的BOM,BOM签名的意思就是告诉编辑器当前文件采用何种编码,方便编辑器识别,
    但是BOM虽然在编辑器中不显示,但是会产生输出,就像多了一个空行。

    我的问题就在于不应该是用BOM格式的,改一下,问题就解决了。

  • 相关阅读:
    ios学习- 10大iOS开发者最喜爱的类库
    Android开发之组件
    2015最新iOS学习线路图
    2015最新Android学习线路图
    2015最全iOS开发自学视频资料(基础+实战)
    linux服务器常用密令
    windows服务器入门 使用FileZilla搭建FTP服务
    windows服务器入门 php的安装
    hdu 1106
    hdu 1040 As Easy As A+B
  • 原文地址:https://www.cnblogs.com/lrxing/p/3580358.html
Copyright © 2011-2022 走看看