Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 24, 2022 06:41 am GMT

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:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To