因此,我有一個小的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