098098 发表于 2015-11-26 09:00:58

php生成rss订阅

//$news为重数据库里取出的数组
$host = $_SERVER['HTTP_HOST'];
$xmls = '<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>';
foreach ($news as $keys => $values) {
//foreach ($values as $key1 => $value1) {
$xmls .= "<item><title>".$values["title"]."</title>";
      $xmls .= "<link>http://$host/news.php?id=".$values['id']."</link>";
      //$xmls .= "<description><![$value1]></description>";
      //$xmls .= "<pubDate>".$values["addtime"]."</pubDate>";
      $xmls .= "<dc:creator>$host</dc:creator>";
      //$xmls .= "<description>".$values["addtime"]."</description>";
      $xmls .="<category><!."]]></category></item>";
      //$xmls .= "</channel>";
//}
}
$xmls .= "</channel></rss>";
echo $xmls;

页: [1]
查看完整版本: php生成rss订阅