Validating fopen

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tomsolli
Forum Newbie
Posts: 1
Joined: Mon Aug 29, 2005 9:34 am

Validating fopen

Post by tomsolli »

Have a rss news feed on my site, and sometimes if the news site is down, I get this message:

Warning: fopen(http://headlinefeeds.news.com.au/servle ... 5&typeid=1): failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error in /home/virtual/site107/fst/var/www/html/griffith/scripts/rsslib.php on line 77
could not open XML input

Is there any way I can put a code in my script that checks if the feed is really there and working, and if not display a message like "News feed currently not available"???

Thanx

TOM
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$handle = @fopen($url);
if($handle === false)
{
  // stream failed connection
}
Post Reply