PHP returns data in json format

PHP returns the json format to specify the data type in the header: Content-Type:application/json, otherwise it will return by default: Content-Type:text/html;

example:

<?php
header('Content-Type:application/json; charset=utf-8');

$arr = [
    'message' => 'success'
    ];

exit(json_encode($arr,256));

Return xml:

header('Content-Type:text/xml; charset=utf-8');

Guess you like

Origin blog.csdn.net/qq_39004843/article/details/112857838