1

I'm new to back end development and i'm trying to learn back end development. What i want is to create a backend using PHP which should output a json response.

For example if there's a field called First Name in my backend,and when i update that field, I want the updated name in a json response so i can display the outputs in my android app.

Sorry for being a noob.

Just point me some tutorials to learn and any further tips would be appreciated.

asked Sep 6, 2015 at 9:30

1 Answer 1

1

Outputting JSON is quite simple, you first set an HTTP Response Header and then print the JSON content. The response header is to tell the receiving application (client) what type of data to expect.

A simple example:

header('Content-Type: application/json');
echo json_encode(array(
 'name' => "Your Name"
));

You didn't mention if you were using a framework or not, but frameworks like Laravel or Lumen make this kind of thing easy.

Here's a tutorial that might be of use to you.

answered Sep 6, 2015 at 10:20
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.