use echo , Basic Simple XML
<?php
header('Content-Type: application/xml');
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo $output;
?>
سؤال
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 ?
المحلول
use echo , Basic Simple XML
<?php
header('Content-Type: application/xml');
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo $output;
?>
نصائح أخرى
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
?>