How can PHP be used to output an RSS feed in XML format?

To output an RSS feed in XML format using PHP, you can create an XML document with the necessary RSS elements such as title, link, description, and items. You can use PHP's built-in functions like `header()` to set the content type as XML and `echo` to output the XML content.

<?php
// Set the content type as XML
header("Content-Type: application/rss+xml; charset=ISO-8859-1");

// Create the XML document for the RSS feed
echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
echo '<rss version="2.0">';
echo '<channel>';
echo '<title>Your RSS Feed Title</title>';
echo '<link>http://www.example.com</link>';
echo '<description>Your RSS Feed Description</description>';

// Add items to the RSS feed
echo '<item>';
echo '<title>Item 1 Title</title>';
echo '<link>http://www.example.com/item1</link>';
echo '<description>Item 1 Description</description>';
echo '</item>';

echo '</channel>';
echo '</rss>';
?>