ForeverSJC ForeverSJC - 22 days ago 10
PHP Question

How to echo <?xml version="1.0" encoding="utf-8"?> in a page?

I'm using a script to display a page in XML, but I need it to display at start but whenever I try, it breaks the code.

Heres the code I tried:

<?php
header('Content-Type: application/xml');
$output = "
<?xml version='1.0' encoding='utf-8' ?>
";
print ($output);
?>


but its not working, any help ?

Answer

use echo , Basic Simple XML

<?php
 header('Content-Type: application/xml');
 $output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 echo $output;
 ?>