I want to return JSON from a PHP script.
Do I just echo the result? Do I have to set the Content-Type header?
Content-Type
The answer to your question is here,
It says.
The MIME media type for JSON text is application/json.
so if you set the header to that type, and output your JSON string, it should work.