Returning JSON from a PHP Script
While you’re usually fine without it, you can and should set the Content-Type header: <?php $data = /** whatever you’re serializing **/; header(‘Content-Type: application/json; charset=utf-8′); echo json_encode($data); If I’m not using a particular framework, I usually allow some request params to modify the output behavior. It can be useful, generally for quick troubleshooting, to not … Read more