XML文档为空,由PHP生成
我试图用PHP制作一个xml文档 但当我尝试这样做时,我得到以下错误:XML文档为空,由PHP生成,php,xml,http-headers,Php,Xml,Http Headers,我试图用PHP制作一个xml文档 但当我尝试这样做时,我得到以下错误: This page contains the following errors: error on line 1 at column 1: Document is empty Below is a rendering of the page up to the first error. 我的消息来源: <?php header('Content-Type: text/xml'); print(htmlentit
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.
我的消息来源:
<?php
header('Content-Type: text/xml');
print(htmlentities('<?xml version="1.0" encoding="UTF-8"?>
<bbcodes>
<block>
<pattern><![CDATA[<p.*?>]]></pattern>
<replace><![CDATA[[p]]]></replace>
</block>
<block>
<pattern><![CDATA[</p>]]></pattern>
<replace><![CDATA[[/p]]]></replace>
</block>
</bbcodes>'));
?>
有什么想法吗?我发现你的代码也有同样的错误。当我删除htmlentities函数时,它工作得很好
<?php
header('Content-Type: text/xml');
print('<?xml version="1.0" encoding="UTF-8"?>
<bbcodes>
<block>
<pattern><![CDATA[<p.*?>]]></pattern>
<replace><![CDATA[[p]]]></replace>
</block>
<block>
<pattern><![CDATA[</p>]]></pattern>
<replace><![CDATA[[/p]]]></replace>
</block>
</bbcodes>');
?>
我收到了与您的代码相同的错误。当我删除htmlentities函数时,它工作得很好
<?php
header('Content-Type: text/xml');
print('<?xml version="1.0" encoding="UTF-8"?>
<bbcodes>
<block>
<pattern><![CDATA[<p.*?>]]></pattern>
<replace><![CDATA[[p]]]></replace>
</block>
<block>
<pattern><![CDATA[</p>]]></pattern>
<replace><![CDATA[[/p]]]></replace>
</block>
</bbcodes>');
?>
为什么要使用htmlentities
?它将把XML转换成文本!我认为应该用它来获得正确的输出。但我错了,我现在明白了。非常感谢:您为什么使用htmlentities
?它将把XML转换成文本!我认为应该用它来获得正确的输出。但我错了,我现在明白了。非常感谢:D