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

首頁 > 語言 > PHP > 正文

PHP RSS 生成類

2024-09-04 11:44:06
字體:
來源:轉載
供稿:網友

同時也可以用網頁來解析xml文檔,PHP RSS 生成類實例代碼如下:

  1. <?php 
  2. if (defined('_class_rss_php')) return
  3. define('_class_rss_php教程',1); 
  4. /** 
  5.  
  6.  *  使用說明: 
  7.  *  $rss = new rss('redfox','http://Vevb.com/',"redfox's blog"); 
  8.  *  $rss->additem('rss class',"http://m.survivalescaperooms.com","xxx",date()); 
  9.  *  $rss->additem(...); 
  10.  *  $rss->savetofile(...); 
  11.  */ 
  12.  
  13. class rss { 
  14.    //public 
  15.    $rss_ver = "2.0"
  16.    $channel_title = ''
  17.    $channel_link = ''
  18.    $channel_description = ''
  19.    $language = 'zh_cn'
  20.    $copyright = ''
  21.    $webmaster = ''
  22.    $pubdate = ''
  23.    $lastbuilddate = ''
  24.    $generator = 'redfox rss generator'
  25.  
  26.  
  27.    $content = ''
  28.    $items = array(); 
  29.  
  30.  
  31.    function rss($title$link$description) { 
  32.        $this->channel_title = $title
  33.        $this->channel_link = $link
  34.        $this->channel_description = $description
  35.        $this->pubdate = date('y-m-d h:i:s',time()); 
  36.        $this->lastbuilddate = date('y-m-d h:i:s',time()); 
  37.    } 
  38.  
  39.  
  40.    function additem($title$link$description ,$pubdate) { 
  41.        $this->items[] = array('titile' => $title , 
  42.                         'link' => $link
  43.                         'description' => $description
  44.                         'pubdate' => $pubdate); 
  45.    } 
  46.  
  47.  
  48.    function buildrss() { 
  49.        $s = "<!--l version="1.0" encoding="gb2312"--> "
  50.        // start channel 
  51.        $s .= " "
  52.        $s .= " " 
  53.        $s .= "<link />{$this->channel_link} "
  54.        $s .= "{$this->channel_description} "
  55.        $s .= "{$this->language} "
  56.        if (!emptyempty($this->copyright)) { 
  57.           $s .= "{$this->copyright} "
  58.        } 
  59.        if (!emptyempty($this->webmaster)) { 
  60.           $s .= "{$this->webmaster} "
  61.        } 
  62.        if (!emptyempty($this->pubdate)) { 
  63.           $s .= "{$this->pubdate} "
  64.        } 
  65.  
  66.  
  67.        if (!emptyempty($this->lastbuilddate)) { 
  68.           $s .= "{$this->lastbuilddate} "
  69.        } 
  70.  
  71.  
  72.        if (!emptyempty($this->generator)) { 
  73.           $s .= "{$this->generator} "
  74.        } 
  75.        
  76.        // start items 
  77.        for ($i=0;$iitems),$i++) { 
  78.            $s .= " "
  79.            $s .= " "
  80.            $s .= "<link />{$this->items[$i]['link']} "
  81.            $s .= "<!--data[{$thi-->items[$i]['description']}]]> "
  82.            $s .= "{$this->items[$i]['pubdate']} ";           
  83.            $s .= " "
  84.        } 
  85.       
  86.       // close channel 
  87.       $s .= " "
  88.       $this->content = $s
  89.    } 
  90.  
  91.  
  92.    function show() { 
  93.        if (emptyempty($this->content)) $this->buildrss(); 
  94.        header('content-type:text/xml'); 
  95.        echo($this->content); 
  96.    } 
  97. //開源代碼Vevb.com 
  98.  
  99.    function savetofile($fname) { 
  100.        if (emptyempty($this->content)) $this->buildrss(); 
  101.        $handle = fopen($fname'wb'); 
  102.        if ($handle === false)  return false; 
  103.        fwrite($handle$this->content); 
  104.        fclose($handle); 
  105.    } 
  106.  
  107. ?> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 合阳县| 谢通门县| 新宁县| 安丘市| 成都市| 会昌县| 婺源县| 阿拉善左旗| 广宁县| 日土县| 扬州市| 曲松县| 卓资县| 榆林市| 察哈| 靖宇县| 兖州市| 永平县| 佛冈县| 永兴县| 新建县| 阿克陶县| 神木县| 白沙| 德格县| 化德县| 保德县| 洛扎县| 民勤县| 济源市| 万州区| 临泽县| 奉节县| 贵溪市| 上犹县| 盈江县| 平谷区| 建始县| 望都县| 吉首市| 喀什市|