HomePHP Page 6 - Rockin’ RSS with PHP on your HTML
Tease the reader - PHP
An RSS feed lets webmasters tease visitors into returning to their websites again and again to check out new content. Danny Wall explains how to set up this simple, automated, spamless way of getting Web surfers to come back for more.
And essentially that’s it. Notice how I did NOT put the entire content into the RSS feed. You can put the entire content into the file if you want. Personally, I don’t recommend doing this. Instead, put just enough to tease the reader so that they want to visit your site.
Now, you will note that I do move the data around just a bit to not only shorten the length of what I’m sending out on the feed, but also to add the ellipses to let readers know there is more.
And again, how you decide to database your content will affect exactly how you pull that content out.
Anyway, at this point, all we need to do is close off the file.
fwrite ($fd, "</channel></rss>"); fclose ($fd);
It is a simple enough process. You can now have that ran by a cron job, or simply run the php file from a browser once a day.
Again, if you are running some sort of a content management system (and I’ll talk about how to easily build your own in future articles), creating the RSS file is obviously a simple matter of writing the static “header” information for your site/feed, pulling the content out of the database, writing each item of new content between “<item>” tags, and then closing the file off with the ending tags.
You may want to add in some other information into this feed, and again, we’ll also talk about what other information there is to add, and why you may want to put that into the feed. We’ll also talk about, if you are adding content via RSS feeds to your site, how to make THAT content from that OTHER feed a part of your own RSS feed. This will ensure that you’ve got a constantly updating RSS feed so that people will want to keep coming back to your site, driving up traffic, unique visitors per day, and page views per visitor.