RSS可以是以下三种解释中任一种的缩写,但其实这三者都是指同一种联合供稿(Syndication)的技术:
这篇文章主要介绍了PHP生成RSS文件类,可实现PHP生成RSS文件的功能,对于网站建设与优化来说具有一定的实用价值,需要的朋友可以参考下
PHP RSS 生成类实例代码如下:
代码如下:
?php if (defined( _html' target='_blank'>class_rss_php )) return; define( _class_rss_php教程 ,1); 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 生成RSS文件类实例代码的详细内容,其它编程语言
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。
新闻热点
疑难解答