由于在输出XML文件之前附加了空格,因此有一个正在制作RSS源的PHP文件会出错。我检查了代码和包含变量$s
的变量,该变量使得XML文件之前没有任何空格。
<?php
header("Content-Type: text/xml; encoding=UTF-8");
$s = "<?xml version='1.0' encoding='UTF-8'?><rss version='2.0'><channel>";
echo ltrim($s);
foreach($this->results as $row)
{
$title=$row->name;
$description=$row->description;
echo "<item><title>$title</title><link>$link</link><description>$description</description></item>";
}
echo "</channel></rss>";
?>
答案 0 :(得分:0)
确保<?php
<?php
header("Content-Type: text/xml; encoding=UTF-8");
$s = "<?xml version='1.0' encoding='UTF-8'?><rss version='2.0'><channel>";
echo ltrim($s);
foreach($this->results as $row)
{
$title=$row->name;
$description=$row->description;
echo "<item><title>$title</title><link>$link</link><description>$description</description></item>";
}
echo "</channel></rss>";
?>