Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

Create RSS Feed Reader Using PHP

Tuesday, Mar 7, 2017

Tags:- HTML PHP


RSS feed is very important for website and their users to get regularly updated for the latest news and articles with the help of RSS feed reader you can view the latest and all previous articles of a website.In this tutorial we will show you how to read RSS feed using PHP.You may also like create rss feed using PHP.


RSS feed reader using PHP


To Create RSS Feed It Takes Only One Step:-

  1. Make a PHP file to display the RSS Feed


Step 1.Make a PHP file to display the RSS Feed

We make a PHP file and save it with a name feed.php

<html>
<head>
<style>
body
{
 width:100%;
 margin:0 auto;
 padding:0px;
 font-family:helvetica;
 background-color:#A9D0F5;
}
#wrapper
{
 text-align:center;
 margin:0 auto;
 padding:0px;
 width:995px;
}
#wrapper h1
{
 margin-top:100px;
 font-size:40px;
}
#wrapper h1 p
{
 font-size:17px;
}
#wrapper #feed_div
{
 background-color:white;
 width:350px;
 height:250px;
 overflow-y:scroll;
 margin-left:320px;
 margin-top:20px;
 text-align:left;
 border:1px solid silver;
 padding:10px;
}
#wrapper #feed_div h2
{
 font-size:17px;
}
#wrapper #feed_div .title a
{
 text-decoration:none;
 color:#0080FF;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="feed_div">
<?php
$rss = simplexml_load_file('http://talkerscode.com/rss.xml');
echo '<h2>'. $rss->channel->title . '</h2>';	
foreach ($rss->channel->item as $item) 
{
 echo '<p class="title"><a href="'. $item->link .'">' . $item->title . "</a></p>";
 echo "<p class='desc'>" . $item->description . "</p>";
} 
?>
</div>
</div>
</body>
</html>

In this step we use simplexml_load_file function of php to load XML we use our XML file to display our feed.Then we display all the article links with description using foreach loop.You may also like create xml sitemap using PHP.


Thats all, this is how to create RSS feed reader using PHP.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Subscribe TalkersCode! One Of The Best
Web Development And Review Blog

Get Latest Tutorials And Reviews
Via Email