An Interest In:
Web News this Week
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
- March 14, 2024
- March 13, 2024
January 24, 2022 06:41 am GMT
Original Link: https://dev.to/sh20raj/returning-json-from-a-php-script-create-rest-api-in-php-3gm5
Returning JSON from a PHP Script - Create Rest API in Php
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);?>
Original Link: https://dev.to/sh20raj/returning-json-from-a-php-script-create-rest-api-in-php-3gm5
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To