How to Use PHP to create an API and draw out an example ...... MYSQL Data is read by the client in JSON format. Write client data into MYSQL through interfaces. I don't know if I can reach out and find a simple example. I don't need to worry about security. I just need to be able to read, write, and probably demonstrate the principle. How to Use PHP to create an API and draw out an example ......
- MYSQL Data is read by the client in JSON format.
- Write client data into MYSQL through interfaces.
I don't know if I can reach out and find a simple example. I don't need to worry about security. I just need to be able to read, write, and probably demonstrate the principle.
Reply content:
How to Use PHP to create an API and draw out an example ......
- MYSQL Data is read by the client in JSON format.
- Write client data into MYSQL through interfaces.
I don't know if I can reach out and find a simple example. I don't need to worry about security. I just need to be able to read, write, and probably demonstrate the principle.
Json_encode ($ data );
Directly output json encoded data.
The client can directly read and decode the data!
Public function getInfo () {$ data = 'select... '; // retrieve the data header ('content-Type: application/json; charset = UTF-8'); // the header is very important: exit (json_encode ($ data ));} public function writeInfo () {$ data =$ _ POST ['example ']; $ result = '... '; // database write operation}