How to return json string in Apache
Steps
- Add string AddType application/json .json to Apache configuation file /etc/apache2/mods-available/mime.conf.
- Enable mime module via a2enmod mime.
- PHP files don’t add any echo html tags string.
<?php
$myObj->name = "John";
$myObj->age = 30;
$myObj->city = "New York";
$myJSON = json_encode($myObj);
echo $myJSON;
?>