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
Set the content type with header('Content-type: application/json'); and then echo your data.
header('Content-type: application/json');