How to output JSON data correctly using PHP

前端 未结 7 1465
时光说笑
时光说笑 2021-01-04 04:03

I\'m developing an Android app, and for the API I\'m sending my requests to a URL that should return JSON data.

This is what I\'m getting in my output:

相关标签:
7条回答
  • 2021-01-04 04:34

    You can pass an argument to the json_encode function like this :

    echo json_encode($response, JSON_PRETTY_PRINT);
    

    PHP 5.2.0 => http://php.net/manual/en/function.json-encode.php

    0 讨论(0)
提交回复
热议问题