What are the best practices for outputting XML declarations in PHP to ensure XHTML conformity?

When outputting XML declarations in PHP to ensure XHTML conformity, it is important to include the correct XML declaration at the beginning of the document. This includes specifying the XML version and encoding. Additionally, it is recommended to set the content type header to "application/xhtml+xml" to inform the browser that the document is XHTML.

<?php
header('Content-Type: application/xhtml+xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>