本文实例讲述了PHP生成RSS文件类文件。分享给大家供大家参考。具体如下:
PHP RSS 生成类实例代码如下:
复制代码 代码如下:<"redfox's blog");
* $rss->additem('rss class',"https://www.jb51.net","xxx",date());
* $rss->additem(...);
* $rss->savetofile(...);
*/
class rss {
//public
$rss_ver = "2.0";
$channel_title = '';
$channel_link = '';
$channel_description = '';
$language = 'zh_cn';
$copyright = '';
$webmaster = '';
$pubdate = '';
$lastbuilddate = '';
$generator = 'redfox rss generator';
$content = '';
$items = array();
function rss($title, $link, $description) {
$this->channel_title = $title;
$this->channel_link = $link;
$this->channel_description = $description;
$this->pubdate = date('y-m-d h:i:s',time());
$this->lastbuilddate = date('y-m-d h:i:s',time());
}
function additem($title, $link, $description ,$pubdate) {
$this->items[] = array('titile' => $title ,
'link' => $link,
'description' => $description,
'pubdate' => $pubdate);
}
function buildrss() {
$s = "<!--l version="1.0" encoding="gb2312"--> ";
// start channel
$s .= " ";
$s .= " "
$s .= "<link />{$this->channel_link} ";
$s .= "{$this->channel_description} ";
$s .= "{$this->language} ";
if (!emptyempty($this->copyright)) {
$s .= "{$this->copyright} ";
}
if (!emptyempty($this->webmaster)) {
$s .= "{$this->webmaster} ";
}
if (!emptyempty($this->pubdate)) {
$s .= "{$this->pubdate} ";
}
if (!emptyempty($this->lastbuilddate)) {
$s .= "{$this->lastbuilddate} ";
}
if (!emptyempty($this->generator)) {
$s .= "{$this->generator} ";
}
// start items
for ($i=0;$iitems),$i++) {
$s .= " ";
$s .= " ";
$s .= "<link />{$this->items[$i]['link']} ";
$s .= "<!--data[{$thi-->items[$i]['description']}]]> ";
$s .= "{$this->items[$i]['pubdate']} ";
$s .= " ";
}
// close channel
$s .= " ";
$this->content = $s;
}
function show() {
if (emptyempty($this->content)) $this->buildrss();
header('content-type:text/xml');
echo($this->content);
}
function savetofile($fname) {
if (emptyempty($this->content)) $this->buildrss();
$handle = fopen($fname, 'wb');
if ($handle === false) return false;
fwrite($handle, $this->content);
fclose($handle);
}
}
?>
希望本文所述对大家的PHP程序设计有所帮助。
PHP,生成,RSS,类
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新动态
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]