国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PHP生成RSS文件類實例

2024-05-04 23:28:40
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了PHP生成RSS文件類,可實現PHP生成RSS文件的功能,對于網站建設與優化來說具有一定的實用價值,需要的朋友可以參考下
 
 

本文實例講述了PHP生成RSS文件類文件。分享給大家供大家參考。具體如下:

PHP RSS 生成類實例代碼如下:

復制代碼代碼如下:
<?php 
if (defined('_class_rss_php')) return; 
define('_class_rss_php教程',1); 
/** 
 
 *  使用說明: 
 *  $rss = new rss('redfox','http://bbs.vevb.com/',"redfox's blog"); 
 *  $rss->additem('rss class',"http://m.survivalescaperooms.com","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程序設計有所幫助。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武宁县| 台东县| 常宁市| 穆棱市| 津南区| 茶陵县| 浦北县| 京山县| 张掖市| 溆浦县| 涿州市| 汾西县| 阿城市| 凤庆县| 比如县| 临沭县| 阿鲁科尔沁旗| 铁力市| 平定县| 玛曲县| 拜泉县| 老河口市| 桐乡市| 彰化市| 福州市| 舒城县| 新巴尔虎右旗| 桃江县| 施秉县| 昆明市| 江安县| 九寨沟县| 台北县| 沅江市| 麦盖提县| 西盟| 石嘴山市| 山东省| 浠水县| 石城县| 额敏县|