因此,我有一个小的PHP脚本,可以为我的博客的RSS源生成xml感觉。然而,它抛出了这个错误:PHP生成RSS XML - 编码错误
This page contains the following errors:
error on line 23 at column 14: Encoding error
Below is a rendering of the page up to the first error.
(这里看到:http://aviatex14.co.uk/rss.xml)
下面是产生它的代码:
while ($line = mysql_fetch_array($result)) {
$return[] = $line;
var_dump(date("Y-m-d H:i:s", $line['timestamp']));
}
$now = date("D, d M Y H:i:s T");
$output = "<?xml version=\"1.0\" encoding=\"UTF-16\" ?>
<rss version=\"2.0\">
<channel>
<title></title>
<link></link>
<description></description>
<pubDate></pubDate>
<language>en-us</language>
<lastBuildDate>$now</lastBuildDate>
";
foreach ($return as $line) {
$output .= "<item><title>".htmlentities($line['title'])."</title>
<link>http://blog.aviatex14.co.uk/permalink.php?uid=".htmlentities($line['uid'])."</link>
<description>".htmlentities(strip_tags($line['entry']))."</description>
<pubDate>".$date = date("Y-m-d H:i:s T", $line['timestamp'])."</pubDate>
</item>";
}
$output .= "</channel></rss>";
print "Content-Type: application/rss+xml";
echo $output;
$f = fopen("rss.xml", "w");
fwrite($f, $output);
fclose($f);
任何帮助,将不胜感激! :D
我想知道什么'htmlentities'在其他地方使用。无论如何,你应该提供一个'charset'来使它至少为它自己工作:http://php.net/manual/en/function.htmlentities.php – hakre
'encoding = \“UTF-16 \”' - 这是真的是输出的真正的编码? – hakre
这条线没有错误了。显然,OP在询问后更改了Feed。投票结束。 – Gordon