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
Try json_encode to encode the data and set the content-type with header('Content-type: application/json');.
header('Content-type: application/json');