Returning JSON from a PHP Script

前端 未结 18 1398
南方客
南方客 2020-11-21 04:59

I want to return JSON from a PHP script.

Do I just echo the result? Do I have to set the Content-Type header?

18条回答
  •  难免孤独
    2020-11-21 05:25

    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.

提交回复
热议问题