Jump to content

RSS feed


runeveryday

Recommended Posts

$feed=file_get_contents('URL');

$rss=new  SimpleXmlElement($feed);

foreach($rss->channel->item as $entry)

{echo "<p><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></p>";} 

who can tell me what the $rss->channel->item mean.

in php,i found state a class's format is

 

class classname{...;}

when refer the content of the class,the format is

$variablename=new classname, $variablename->the content of the class,however,in the above example,i found there is now state channel in SimpleXmlElement($feed);why?

i am a beginner of php and expect some can explain these details.

 

thank you!

Link to comment
https://forums.phpfreaks.com/topic/167562-rss-feed/
Share on other sites

$feed=file_get_contents('URL');

$rss=new  SimpleXmlElement($feed);

foreach($rss->channel->item as $entry)

{echo "<p><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></p>";} 

who can tell me what the $rss->channel->item mean.

in php,i found state a class's format is

 

class classname{...;}

when refer the content of the class,the format is

$variablename=new classname, $variablename->the content of the class,however,in the above example,i found there is now state channel in SimpleXmlElement($feed);why?

i am a beginner of php and expect some can explain these details.

 

thank you!

 

$rss is an object. channel could be a function of the object. item could be a variable of the object. Fairly simple if you understand OOP.

Link to comment
https://forums.phpfreaks.com/topic/167562-rss-feed/#findComment-883666
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.