Home> PHP Framework> ThinkPHP> body text

Simple small example of API interface development based on thinkphp6.x

藏色散人
Release: 2020-12-11 16:02:54
forward
4790 people have browsed it

The following tutorial column ofthinkphp frameworkwill introduce to you a simple small example of API interface development based on thinkphp6.x. I hope it will be helpful to friends in need!

Simple small example of API interface development based on thinkphp6.x

A simple small example of API interface development - based on thinkphp6.x

Mainly helpful for PHP children who have never been exposed to interface development. That is: the front end submits a product ID and returns product details; there is no authentication or anything else, it is just used to understand the process and become proficient from getting started

A simple small example of API interface development - based on thinkphp6.x, the code is as follows:

Step 1: Front-end code (requester) view/index/index.html:

    API接口开发简单小实例-基于thinkphp6.x 
Copy after login

Step 2: Controller code (requester) controller/index.php:


        
Copy after login

Step 3: API interface, code controller/goods.php:

where('id',$goods_id)->find(); // 返回数据 return json($data);//print_r($data); } }
Copy after login

The above is the detailed content of Simple small example of API interface development based on thinkphp6.x. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:南国老符
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!