How can PHP be used to ensure proper header (Content-Type) assignment for XML files?

When serving XML files using PHP, it is important to set the correct Content-Type header to ensure proper rendering in the browser. This can be done using the header() function in PHP to explicitly set the Content-Type to "application/xml" before outputting the XML content.

<?php
// Set the Content-Type header to ensure proper rendering of XML
header('Content-Type: application/xml');

// Output the XML content
echo '<?xml version="1.0" encoding="UTF-8"?>
<root>
  <element>Example</element>
</root>';
?>