Question

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 ?

Was it helpful?

Solution

use echo , Basic Simple XML

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

OTHER TIPS

yes, use echo, but you don't need additional variable and you can use single quote string without backslash...

<?php
header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="UTF-8"?' . ">\n"; //connate strings to protect end of php formatting in simple editors, and use new line tag
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top