av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

PHP 實現(xiàn)RSS訂閱類

瀏覽:4日期:2022-09-12 16:57:57

?<?phpclass RSS{ /** +---------------------------------------------------------- * RSS頻道名 +---------------------------------------------------------- */ protected $channel_title = ’’; /** +---------------------------------------------------------- * RSS頻道鏈接 +---------------------------------------------------------- */ protected $channel_link = ’’; /** +---------------------------------------------------------- * RSS頻道描述 +---------------------------------------------------------- */ protected $channel_description = ’’; /** +---------------------------------------------------------- * RSS頻道使用的小圖標的URL +---------------------------------------------------------- */ protected $channel_imgurl = ’’; /** +---------------------------------------------------------- * RSS頻道所使用的語言 +---------------------------------------------------------- */ protected $language = ’zh_CN’; /** +---------------------------------------------------------- * RSS文檔創(chuàng)建日期,默認為今天 +---------------------------------------------------------- */ protected $pubDate = ’’; protected $lastBuildDate = ’’; protected $generator = ’YBlog RSS Generator’; /** +---------------------------------------------------------- * RSS單條信息的數(shù)組 +---------------------------------------------------------- */ protected $items = array(); /** +---------------------------------------------------------- * 構(gòu)造函數(shù) +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @param string $title RSS頻道名 * @param string $link RSS頻道鏈接 * @param string $description RSS頻道描述 * @param string $imgurl RSS頻道圖標 +---------------------------------------------------------- */ public function __construct($title, $link, $description, $imgurl = ’’) {$this->channel_title = $title;$this->channel_link = $link;$this->channel_description = $description;$this->channel_imgurl = $imgurl;$this->pubDate = Date(’Y-m-d H:i:s’, time());$this->lastBuildDate = Date(’Y-m-d H:i:s’, time()); } /** +---------------------------------------------------------- * 設(shè)置私有變量 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @param string $key 變量名 * @param string $value 變量的值 +---------------------------------------------------------- */ public function Config($key,$value) {$this->{$key} = $value; } /** +---------------------------------------------------------- * 添加RSS項 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @param string $title 日志的標題 * @param string $link 日志的鏈接 * @param string $description 日志的摘要 * @param string $pubDate 日志的發(fā)布日期 +---------------------------------------------------------- */ function AddItem($title, $link, $description, $pubDate) {$this->items[] = array(’title’ => $title, ’link’ => $link, ’description’ => $description, ’pubDate’ => $pubDate); } /** +---------------------------------------------------------- * 輸出RSS的XML為字符串 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ public function Fetch() {$rss .= '<?xml version='1.0' encoding='utf-8' ?>rn';$rss .= '<rss version='2.0'>rn';$rss .= '<channel>rn';$rss .= '<title><![CDATA[{$this->channel_title}]]></title>rn';$rss .= '<description><![CDATA[{$this->channel_description}]]></description>rn';$rss .= '<link>{$this->channel_link}</link>rn';$rss .= '<language>{$this->language}</language>rn'; if (!empty($this->pubDate)) $rss .= '<pubDate>{$this->pubDate}</pubDate>rn';if (!empty($this->lastBuildDate)) $rss .= '<lastBuildDate>{$this->lastBuildDate}</lastBuildDate>rn';if (!empty($this->generator)) $rss .= '<generator>{$this->generator}</generator>rn'; $rss .= '<ttl>5</ttl>rn'; if (!empty($this->channel_imgurl)) { $rss .= '<image>rn'; $rss .= '<title><![CDATA[{$this->channel_title}]]></title>rn'; $rss .= '<link>{$this->channel_link}</link>rn'; $rss .= '<url>{$this->channel_imgurl}</url>rn'; $rss .= '</image>rn';} for ($i = 0; $i < count($this->items); $i++) { $rss .= '<item>rn'; $rss .= '<title><![CDATA[{$this->items[$i][’title’]}]]></title>rn'; $rss .= '<link>{$this->items[$i][’link’]}</link>rn'; $rss .= '<description><![CDATA[{$this->items[$i][’description’]}]]></description>rn'; $rss .= '<pubDate>{$this->items[$i][’pubDate’]}</pubDate>rn'; $rss .= '</item>rn';} $rss .= '</channel>rn</rss>';return $rss; } /** +---------------------------------------------------------- * 輸出RSS的XML到瀏覽器 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public function Display() {header('Content-Type: text/xml; charset=utf-8');echo $this->Fetch();exit; }}

?>

標簽: PHP
相關(guān)文章:
主站蜘蛛池模板: 荤话粗俗h高h重口 | 国产成人91 | 国产一区久久 | 国产激情久久久 | 黄色三级在线 | 国产黄色一级片 | 久久最新视频 | 午夜丁香 | 国产一级片网站 | 国产精品日韩在线 | 国产三级在线看 | 亚洲天堂av网 | 97精品国产97久久久久久免费 | 看片黄全部免费 | 久久久91| 免费一级黄色片 | 不卡免费视频 | 国产91清纯白嫩初高中在线观看 | 欧美成人一级片 | 国产一级片免费看 | 天天躁日日躁bbbbb | 精品久久久久久久久久 | 午夜av在线播放 | 91视频日本 | 久热中文字幕 | 综合在线视频 | 欧美日本在线 | 久久久精品在线 | 黄色免费视频网站 | 日本久久网站 | 人人超碰在线 | 国产精品福利在线观看 | 日韩精品免费视频 | 日韩中文字幕免费 | 日韩黄色网址 | 中文字幕亚洲综合 | 91蝌蚪91九色白浆 | 国产精品伦一区二区三级视频 | 一级毛片在线播放 | 久久888 | 国产青青草 |