Beanno1116
Beanno1116

Reputation: 239

echo'ing XML in PHP

why wont the following echo out the strings?

    <?php

    header("Content=type: text/xml");

    echo '<?xml version="1.0" ?>';
    echo '<strains>';
    echo '<strainName>';
    echo '</strainName>';
    echo '</strains>';


    ?>

Basically I am experimenting with php and xml and noticed that when i create this script and run it, nothing is outputed to the screen?

Upvotes: 0

Views: 179

Answers (2)

Vikram
Vikram

Reputation: 8333

The declaration of MIME type is incorrect. It should be:

header('Content-type: text/xml');

Upvotes: 2

Juanma
Juanma

Reputation: 1661

Works fine for me. Open your php.ini and set the option

short_open_tag = Off

After that, restart your server.

Upvotes: 1

Related Questions