This class makes it easy to create an RSS Feed. I followed The Official RSS 2.0 Specifications at Harvard Law to a tee when creating this class, and the following websites were also helpful:

You don't have to worry about formatting any of your dates as we do all of that in-house. Any date that can be translated by PHP's strtotime() function will do just fine. After you're done, Validate Your RSS Feed to make sure you got things right. Finally, place the following at the top of every page that corresponds to your RSS Feed so that browsers will recognize it:

$page->link('<link rel="alternate" type="application/rss+xml" href="" title="Your title" />');

This is the constructor for the class, and it takes in the three required channel elements to get your RSS feed on it's feet.

$title The name of your RSS feed.
$link The website link that corresponds to the feed.
$description A short description of your feed.
Returns An RSS object.
$rss = new RSS ('My RSS Feed', '', 'The latest news from my website.');

This method allows you to insert all of the other optional channel elements into your feed. See the examples below. You don't have to keep calling this method for every element, you can just throw everything into an array and call the method only once.

$elements Key and value pairs of channel elements, and their values.
$rss->channel(array('atom:link'=>array('href'=>'', 'rel'=>'self', 'type'=>'application/rss+xml'), 
                    'pubDate'=>'2010-10-28 09:52:33', 
                    'generator'=>'The awesome RSS Class at!' 

According to the RSS Advisory Boards recommended best practices, this atom:link should be included in your feed, and it should point to the RSS Feed URL itself.

$rss->channel(array('atom:link'=>array('href'=>'', 'rel'=>'self', 'type'=>'application/rss+xml')));

The language the channel is written in. See the Allowable values for language in RSS.


A copyright notice for the channel.

$rss->channel(array('copyright'=>'Copyright 2010 Website'));

The email address of who is responsible for the content.


The email address of who is responsible for any techincal issues relating to the feed.


The channel's publication date.


The last time the content in the feed changed.


A general category that the feed would fall under.


Any software kudos you would like to give.

$rss->channel(array('generator'=>' RSS Class'));

A URL that points to the documentation for the format used in the RSS file.


To specify a web service that supports the rssCloud interface. See SOAP meets RSS.


"Time To Live" - How long (in seconds) a channel should be cached before the source is refreshed.


A jpg, gif, or png image to display with the channel. The 'url', 'title', and 'link' values are required, the rest are optional. 'title' and 'link' should have the same values as the channel's title and link.

                                   'title'=>'My RSS Feed', 
                                   'width'=>'144', // (max - default is 88) 
                                   'height'=>'400', // (max - default is 31) 
                                   'description'=>'a few thoughts...' 

The PICS (an outdated protocol to describe web content) rating for the channel.

$rss->channel(array('rating'=>'(PICS-1.1 "" l r (SS~~000 1))'));

A text input box. Most aggregators ignore it. The purpose for this element is unclear.

                                       'description'=>'Search Google', 

An array of hours (between 0 and 23) when you don't want aggregators to read your channel.

$rss->channel(array('skipHours'=>array(16, 17, 18)));

An array of days ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') when you don't want aggregators to read your channel.

$rss->channel(array('skipDays'=>array('Saturday', 'Sunday')));

This method creates an item in your feed. The only required element is either the 'title', or a 'description'. We settled on requiring a title.

$title The title of the item.
$elements Key and value pairs of item elements, and their values. See below for examples.
$rss->item('Item Title', 
                 'description'=>'A description of the item.', 
                 'pubDate'=>'2004-08-15 16:23:42'));

The url link of the item.

$elements['link'] = '';

A description of the item. To include html in your description then wrap it in CDATA tags like so:
<![CDATA[An <b>HTML</b> description.]]>

$elements['description'] = 'A description of the item.';

The author's email address.

$elements['author'] = '';

A category that the item belongs to.

$elements['category'] = 'news';

A url address where comments for the item are located.

$elements['comments'] = '';

A media object attached to the item. All three attributes ('url, 'length', and 'type') are required.

$elements['enclosure'] = array('url'=>'', 

A "globally unique identifier" for the item. It can be a string, url, number . . . anything as long as it remains unique. If you would like to include the 'isPermaLink' attribute, just make it an array.

$elements['guid'] = ''; // or . . . 
$elements['guid'] = array('isPermaLink'=>'true', 'value'=>''); // meaning this is a url that can be opened in a browser

When the item was published.

$elements['pubDate'] = '2004-08-15 16:23:42';

The name (title) of the RSS channel that the item came from. It has a required 'url' attribute, so define it like so:

$elements['source'] = array('url'=>'', 'value'=>"Other Guy's RSS Feed");

This method puts the whole RSS Feed together, sets the appropriate header, echo's the xml, then exits the script.