PHP 生成RSS 类
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()); } /** +---------------------------------------------------------- * 设置私有变量 +---------------------------------------------------------- * @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 日志的发布日期 +---------------------------------------------------------- */ 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 = "\r\n"; $rss = "\r\n"; $rss .= "\r\n"; $rss .= "channel_title}]]>\r\n"; $rss .= "channel_description}]]>\r\n"; $rss .= "{$this->channel_link}\r\n"; $rss .= "{$this->language}\r\n"; if (!empty($this->pubDate)) $rss .= "{$this->pubDate}\r\n"; if (!empty($this->lastBuildDate)) $rss .= "{$this->lastBuildDate}\r\n"; if (!empty($this->generator)) $rss .= "{$this->generator}\r\n"; $rss .= "5\r\n"; if (!empty($this->channel_imgurl)) { $rss .= "\r\n"; $rss .= "channel_title}]]>\r\n"; $rss .= "{$this->channel_link}\r\n"; $rss .= "{$this->channel_imgurl}\r\n"; $rss .= "\r\n"; } for ($i = 0; $i < count($this->items); $i++) { $rss .= "\r\n"; $rss .= "items[$i]['title']}]]>\r\n"; $rss .= "{$this->items[$i]['link']}\r\n"; $rss .= "items[$i]['description']}]]>\r\n"; $rss .= "{$this->items[$i]['pubDate']}\r\n"; $rss .= "\r\n"; } $rss .= "\r\n"; return $rss; } /** +---------------------------------------------------------- * 输出RSS的XML到浏览器 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public function Display() { header("Content-Type: text/xml; charset=utf-8"); echo $this->Fetch(); exit; } } ?>
登入後複製
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章
<🎜>:種植花園 - 完整的突變指南
3 週前
By DDD
<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
如何修復KB5055612無法在Windows 10中安裝?
3 週前
By DDD
北端:融合系統,解釋
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
3 週前
By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)