Create RSS feed for a website in PHP

Short for Really Simple Syndication or Rich Site Summary, it’s the way to communicate to your website. If you like a website that producing good content, you need to check the website every day to read latest updates. That’s where RSS comes to help . If they have RSS feeds in their website you can just subscribe it in a RSS reader, so RSS reader tool will capture the latest entries for you and you can read it later.

In this tutorial I am demonstrating a simpel RSS feed script, that let you to create a dynmaic RSS feed for your beautiful website.

You can see the below file for basic sample RSS feed

This is a basic RSS structure that is essential for any website. It starts with the usual RSS encoding tag, and then it indicates the version of RSS in the next line with <rss> tag. The main RSS content comes under the <channel> tag. In side you can see that <item> tag is repeating, that will be the main items. <item> tag contains a <title>, <link>, <description> tag to describe your content in the site.

So we are starting with a database that we want to store all the entries for our website.

Next we create a feed.php page to create the RSS feed for the website.

We got all the necessary tags printed in the xml document. Now you submit this RSS feed to different feed publisher websites like Feedly, Feedburner etc.

 

Editorial Staff
 

Editorial Staff at tutsplanet is a dedicated team to write various tutorial articles.