R
R
Rodion Yurchenko2015-09-21 10:16:47
PHP
Rodion Yurchenko, 2015-09-21 10:16:47

How to respond with json?

Hello everyone)
There is a server in php
There is an ios application that expects a json response from the server
The server responds like this:
echo json_encode($data);
But
on ios the header comes that the answer is {text/html}
I understand that this echo is to blame
Tell me how to make it so that json comes, i.e. in the headers there should be {text/json}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2015-09-21
@aassdds

mmm ... specify this same header() in the answer?
header('Content-Type: application/json');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question