Hosting JSON

In this section, we will be creating a PHP script that will allow us to send a JSON feedback to the user upon a successful request. Let's take a look at the index.php file, which accomplishes this task:

Hosting JSON

In this PHP script, we have created a basic students array and are generating the JSON feed for that array. The students array contains basic student information, such as the first name, last name, student ID, and the classes that the student has enrolled.

This file has to be placed in the www folder, and it should be on the same level as the default index.html file that comes with the LAMP installation. Refer to the folder structure in ...

Get JavaScript and JSON Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.