Quantcast
Viewing latest article 2
Browse Latest Browse All 2

Zend_Rss_Feed_Reader -> How to avoid exception if the feed source gets invalid?

I had the following:

  $feedUrl = 'http://www.something.org/?feed=rss2';  $feed = Zend_Feed_Reader::import($feedUrl);  $lastNews = array();   //etc...  return $lastNews;

The problem was that, if the feed didn't exist for somereason, Zend will throw an exception and all my website will stay useless with that exception message.

I end up doing like this:

try {  $feedUrl = 'http://www.something.org/?feed=rss2';  $feed = Zend_Feed_Reader::import($feedUrl);  $lastNews = array();   //etc...  return $lastNews;}catch (Exception $e){   return false;}

It works, but I just made up this. Not sure if it's ok. Any suggestions?

Regards,MEM


Viewing latest article 2
Browse Latest Browse All 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>