How can PHP be used to output an XML declaration despite it not being a traditional XML file?

When outputting XML in PHP, it's important to include an XML declaration at the beginning of the document. This declaration specifies the version of XML being used and the character encoding. Even if the PHP file itself is not a traditional XML file, the XML declaration can still be added using PHP code.

<?php
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
// Other XML content goes here
?>