加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP生成RSS XML – 编码错误

发布时间:2020-12-13 17:38:31 所属栏目:PHP教程 来源:网络整理
导读:所以我有一个小的 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://
所以我有一个小的 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

解决方法

它在那条线上说“TOKYO A Japanese”(并且在饲料中也是如此). 不是utf-8.尝试 utf8_encode(或 iconv,如果你想要一个不同的编码)内容甚至更好: use an XML processor创建提要.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读