Overview
Use PHP’s if…else statement to hide error messages on a web page when an imported RSS feed is unavailable.
Sample error message(s):
Warning: simplexml_load_file(http://username.tumblr.com/no-rss) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/user/public_html/feed.php on line 123
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity “http://username.tumblr.com/no-rss” in /home/user/public_html/feed.php on line 123
Requirements
- Web server with PHP installed
- FTP or shell access
- Text editor
Installation
Note: The following example uses a PHP foreach loop to limit the number of feed items displayed.
- Change the “7″ in the second if statement to the desired number of items. The default number of items in a Tumblr RSS feed is 20.
- Replace the URI in the simplexml_load_file() function with the appropriate feed.
- Replace the output in the second echo statement with a corresponding message.
- Save the web page as a PHP file. Test the new feed in a web browser.
- [Optional] Enter a broken link (in step 2) and the message (in step 3) will display.
Reference:
Advertisement

