찾다
php教程php手册一个生成RSS2.0的php类

rss

/*****************************************
*           RSS2.0 Generator
*          Create by MagicBoy(darasion)
*          Copyright ? 神奇男孩
******************************************/

/*————————————————

使用方法:
将下面的数组,带入相应的函数。

1、频道主体
$channel = array(
 title => '频道名称(必备)',
 link => '频道的URL(必备)',
 description => '频道的描述(必备)',
 language => '频道文章所用语言(可选)',
 webmaster => '负责频道技术事务的网站管理员email(可选)',
 managingEditor => '责任编辑的email(可选)',
 pubDate => '频道内容发布日期,格式遵循RFC822格式(年份可为2位或4位)(可选)',
 lastBuildDate => '频道内容最后的修改日期(Sat, 07 Sep 2002 09:42:31 GMT)(可选)',
 skipDays => '提示新闻聚合器,那些天它可以跳过。(可选)',
 copyright => '频道内容的版权说明(可选)',
 ttl => '有效期,用以指明该频道可被缓存的最长时间(可选)',
);

2、频道图片
$image = array(
 url => '图片的链接(必备)',
 title => '图片的标题,用于http的alt属性(必备)',
 link => '网站的url(实际中常以频道的url代替)(必备)',
 width => '图片的宽度(象素为单位)最大144,默认88(可选)',
 height => '图片的高度(象素为单位)最大400,默认31(可选)',
 description => '用于link的title属性(可选)'
   );

3、频道项
$item = array(
 title => '项(item)的标题(必备)',
 description => '项的大纲(必备)',
 link => '项的URL(必备)',
 comments => '该项的评论(comments)页的URL(可选)',
 guid => '1项的唯一标志符串(可选)',
 author => '该项作者的email(可选)',
 enclosure => '描述该附带的媒体对象(可选)',
 category => '包含该项的一个或几个分类(catogory)(可选)',
 pubdate => '项的发布时间(可选)',
 source_url => '该项来自的RSS道(可选)',
 source_name => '该项来自的RSS道(可选)'
);
————————————————*/

class rss2
{
 var $channel_pre="";
 var $str_image="";
 var $str_item="";
 var $channel_end="";
 /*构造函数*/
 function rss2($channel,$encoding="GB2312")
  {
   $this->channel($channel,$encoding);
  }
 /*生成频道主体*/
 function channel($channel,$encoding="GB2312")
  {
  $this->channel_pre.="\n";
  $this->channel_pre.= "\n";

  $this->channel_pre.= " \n";

  $this->channel_pre.= "  ".$channel['title']."\n";//频道名称(必备)
  $this->channel_pre.= "  ".$channel['link']."\n";//频道的URL(必备)
  $this->channel_pre.= "  ".$channel['description']."\n";//频道的描述(必备)
  $this->channel_pre.= "  MagicBoy RSS Generator v1.0\n";//创建此文档的程序(可选)

  if(isset($channel['language']))$this->channel_pre.= "  ".$channel['language']."\n";//频道文章所用语言(可选)
  if(isset($channel['webmaster']))$this->channel_pre.= "  ".$channel['webmaster']."\n";//负责频道技术事务的网站管理员email(可选)
  if(isset($channel['managingeditor']))$this->channel_pre.= "  ".$channel['managingeditor']."\n";//责任编辑的email(可选)
  if(isset($channel['pubdate']))$this->channel_pre.= "  ".$channel['pubdate']."\n";//频道内容发布日期,格式遵循RFC822格式(年份可为2位或4位)(可选)
  if(isset($channel['lastbuilddate']))$this->channel_pre.= "  ".$channel['lastbuilddate']."\n";//频道内容最后的修改日期(Sat, 07 Sep 2002 09:42:31 GMT)(可选)
  if(isset($channel['skipdays']))$this->channel_pre.= "  ".$channel['skipdays']."\n";//提示新闻聚合器,那些天它可以跳过。(可选)
  if(isset($channel['copyright']))$this->channel_pre.= "  ".$channel['copyright']."\n";//频道内容的版权说明(可选)
  if(isset($channel['ttl']))$this->channel_pre.= "  ".$channel['ttl']."\n";//有效期,用以指明该频道可被缓存的最长时间(可选)

  $this->channel_end.= " \n";
  $this->channel_end.= "\n";
 }
 /*生成频道图片*/
 function image($image)
 {
  if(isset($this->str_image))unset($this->str_image);
  $this->str_image.= "  \n";
  if(isset($image['url']))$this->str_image.= "   ".$image['url']."\n";//图片的url(必备)
  if(isset($image['title']))$this->str_image.= "   ".$image['title']."\n";//图片的标题,用于http的alt属性(必备)
  if(isset($image['link']))$this->str_image.= "   ".$image['link']."\n";//网站的url(实际中常以频道的url代替)(必备)
  if(isset($image['width']))$this->str_image.= "   ".$image['width']."\n";//图片的宽度(象素为单位)最大144,默认88(可选)
  if(isset($image['height']))$this->str_image.= "   ".$image['height']."\n";//图片的高度(象素为单位)最大400,默认31(可选)
  if(isset($image['description']))$this->str_image.= "   ".$image['description']."\n";//用于link的title属性(可选)
  $this->str_image.= "  \n";
 }
 /*频道项*/
 function item($item)
 {
  $this->str_item.="  \n";
  $this->str_item.="   ".$item['title']."\n";//项(item)的标题(必备)
  $this->str_item.="   ".$item['description']."\n";//项的大纲(必备)
  $this->str_item.="   ".$item['link']."\n";//项的URL(必备)

  if(isset($item['comments']))$this->str_item.="   ".$item['comments']."\n";//该项的评论(comments)页的URL(可选)
  if(isset($item['guid']))$this->str_item.="   ".$item['guid']."\n";//1项的唯一标志符串(可选)
  if(isset($item['author']))$this->str_item.="   ".$item['author']."\n";//该项作者的email(可选)
  if(isset($item['enclosure']))$this->str_item.="   ".$item['enclosure']."\n";//描述该附带的媒体对象(可选)
  if(isset($item['category']))$this->str_item.="   ".$item['category']."\n";//包含该项的一个或几个分类(catogory)(可选)
  if(isset($item['pubdate']))$this->str_item.="   ".$item['pubdate']."\n";//项的发布时间(可选)
  if(isset($item['source_url']))$this->str_item.="   ".$item['source_name']."\n";//该项来自的RSS道(可选)
  $this->str_item.="  \n";
 }
 /*输出xml*/
 function generate()
 {
  if(isset($this->channel_pre)&&isset($this->channel_end)&&isset($this->str_item))
  {
   Header("Content-type:text/xml");
   echo $this->channel_pre;
   echo $this->str_image;
   echo $this->str_item;
   echo $this->channel_end;
  }
 }
 /*擦除频道*/
 function erase_channel()
 {
  unset($this->channel_pre);
  unset($this->channel_end);
 }
 /*擦除频道图片*/
 function erase_image()
 {
  unset($this->str_image);
 }
 /*擦除项目*/
 function erase_item()
 {
  unset($this->str_item);
 }
 /*擦除所有*/
 function erase()
 {
  $this->erase_channel();
  $this->erase_image();
  $this->erase_item();
 }
}
?>

 



성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구