While it's usually fine without it, you can and should set theContent-Typeheader:
If I'm not using a specific framework, I usually allow some request parameters to modify the output behavior. Often for quick troubleshooting it can be useful to not send the header, or sometimesprint_rthe data payload to observe it (although in most cases this is not necessary).
The complete and clear PHP code that returns JSON is:
While it's usually fine without it, you can and should set the
Content-Type
header: