How do I create mysql-PHP APIs?

Source: Internet
Author: User
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 ......

  1. MYSQL Data is read by the client in JSON format.
  2. 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 ......

  1. MYSQL Data is read by the client in JSON format.
  2. 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}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.