How can the data queried by php be returned to the front end?

clipboard.png
php code is as follows

Jun.27,2022

change header first

header('Content-Type: application/json');

then remove the last ? >

after the final json_encode, you can directly use echo or die to return the output.
it is recommended to define a uniform API return format and develop it as a method.

Menu