Generate RSS with PHP


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <rss version="2.0">
  3. <channel>
  4. <title>PHP generate RSS feed</title>
  5. <link>http://example.com/</link>
  6. <description>PHP generate RSS feed</description>
  7. <language>de-de</language>
  8. <copyright>Copyright (C) <?php echo date('Y'); ?> example.com</copyright>
  9. <?php
  10. $params = array('newest' => true, 'limit' => '0,10', 'where' => '1=1', 'order' => 'id DESC');
  11.  
  12. //procedure for getting entities for your PHP generated RSS
  13. $listOfEntities = getList( $params );
  14.  
  15. foreach($listOfEntities as $entity) :
  16. ?>
  17.  
  18. <item>
  19. <title><?php echo $entity['title']; ?></title>
  20. <description><?php echo $entity['description']; ?></description>
  21. <link>http://example.com/<?php echo $entity['url']; ?></link>
  22. </item>
  23. <?php
  24. endforeach;
  25. ?>
  26. </channel>
  27. </rss>

URL: http://stuntsnippets.com/php-generate-rss/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.