Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8777901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:23:33+00:00 2026-06-13T19:23:33+00:00

It is not so bad rendering RSS feeds from an index.php page I have

  • 0

It is not so bad rendering RSS feeds from an index.php page I have seen a lot of examples of it. But I am having problems doing it from a class. This is what I have and I am sure I have many errors… PHP is not my strong point so if you could let me know where i am going wrong i would apprecite it…

<?php
class RssDisplay {

protected $fromrss;
protected $allitemscollected_feed;


public function __construct($urllink, $total_items){

    $this->fromrss = $urllink;
    $this->allitemscollected_feed = $total_items;

}

public function getItems($allitemscollected_feed){

    $feed = simplexml_load_file($this->fromrss, $this->allitemscollected_feed);

    return $feed;

    $collected_items[] =$feed;

    $this->set('collected_items', $collected_items);

}

foreach('allitemscollected' as $feed){
    $items->title;
    $items->pubDate;
    $items->description;


}


 } 

from my index this is what I am doing:

 $feed = new RssDisplay('http://feeds.feedburner.com/insidethehall?format=xml');
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:23:34+00:00Added an answer on June 13, 2026 at 7:23 pm

    For starters i would advice you to take a look at Foreach and PHP OPP Basics because

    • Your foreach is not in any method
    • foreach('allitemscollected' as $feed){ is not valid because foreach first argument needs to be array_expression
    • You class is wrong
    • You did not print or echo anything
    • return $feed; was called early which would make other codes invisible
    • $this->set( method those not exists yet it was called $this->set('collected_items', $collected_items);
    • simplexml_load_file second argument needs to be a valid class name that extends SimpleXMLElement yet an integer is passed

    Your Simple Class you look like this

    class RssDisplay {
        protected $maxItems;
        private $xml;
    
        public function __construct($url, $maxItems = 0) {
            $this->xml = simplexml_load_file($url, "SimpleXMLIterator");
            $this->maxItems = $maxItems;
        }
    
        public function getItems() {
            return $this->xml->channel->item;
        }
    
        public function simpleDisplay() {
            $it = ($this->maxItems == 0) ? $this->xml->channel->item : new LimitIterator($this->xml->channel->item, 0, $this->maxItems);
            foreach ( $this->xml->channel->item as $feed ) {
                printf("<div><h2><a href='%s'>%s</a></h2><i>%s</i><p>%s</p></div><br />", $feed->link, $feed->title, $feed->pubDate, $feed->description);
            }
        }
    }
    
    
    $rss = new RssDisplay("http://feeds.feedburner.com/insidethehall?format=xml");
    $rss->simpleDisplay();
    

    Output

    Grantland previews the Hoosiers

    Fri, 02 Nov 2012 19:22:21 +0000

    Grantland: College Basketball Team Previews: Indiana There’s no shortage of offensive firepower with the Hoosiers, and the great thing about Tom Crean is that he’s never afraid to use it. Indiana was well inside the top half of the country in tempo last season, and with an extra year of chemistry it’s a good bet […]

    Notebook: Creek shines in return from injury

    Fri, 02 Nov 2012 02:57:32 +0000

    Maurice Creek got off the bench and walked toward the Assembly Hall scorer’s table with just over 11 minutes left in the first half of Thursday night’s exhibition game against Indiana Wesleyan. Creek checked in with the official scorer, then waited patiently for the moment he’s been thinking about for more than 20 months — […]

      ....... So may more
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen a lot of posts on this, but people have written that it's
Is it bad practice to have a custom cursor on a website? Not just
I know this might sounds not reasonable, and might be a bad design. But
Is it a bad practice to have backbone views which do not depend on
Please do NOT comment on bad practices used here. I am simply trying to
Does anyone see a problem with this, its not working saying bad file descriptor
This bad boy just does not want to change size to fill the dock
Is it bad javascript practice to not assign a newly created object to a
Sorry for the bad title - I simply do not know what to call
Since multiple inheritance is bad (it makes the source more complicated) C# does not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.