View PHP XML files in Firefox (and other browsers)

I have a PHP file that has something in common with XML output. However, whenever I view this PHP file through Firefox (I have not tried IE or Chrome), I get the source code as shown in this image:

http://numberonekits.com/Screenshot.png

It seems to me that since the file is a PHP file, Firefox interprets it as such and does not try to display it as an XML tree, despite its XML header. I know that one solution would be to send the output to a separate file with the extension .xml, but I know that there should be an easier way. I guess I'm really trying to figure out how to get Firefox to recognize the XML format and display it properly. Any help is appreciated.

+5
source share
1 answer

Tell the browser that you are sending it an XML file:

header('Content-Type: text/xml');
+12
source

All Articles