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.

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.