The PHP Manual has this example:
The important points is that you must send a Content-Type header. Also, you must be careful not include any extra white space (like newlines) in your file before or after the
As suggested in the comments, you can avoid the danger of extra white space at the end of your script by omitting the
You still need to carefully avoid white space at the top of the script. One particularly tricky form of white space is a UTF-8 BOM. To avoid that, make sure to save your script as "ANSI" (Notepad) or "ASCII" or "UTF-8 without signature" (Emacs) or similar.