使用 REST API 从表中获取数据

编程入门 行业动态 更新时间:2024-10-26 00:26:17
本文介绍了使用 REST API 从表中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 Slim 框架设计 REST api.我正在使用数据库 mySql.我正在用 php 设计这个 API.

I am designing REST api using Slim framework. I am using database mySql. and i am designing this API in php.

我正在尝试从我的表中获取有关学生的数据.

I am trying to fetch data about student from my table.

我正在尝试这样:-

<?php header('Content-type: application/json'); // Include the Slim library require 'Slim/Slim.php'; // Instantiate the Slim class $app = new Slim(); // Create a GET-based route $app->get('/hello/:name', 'hello'); function hello($name) { // here is code to access detail of $name echo $name // how can i get detail if i have value of name=:kuntal not name=kuntal } // Ready the routes and run the application $app->run(); ?>

我正在使用这个 url 尝试这个功能:-192.168.1.101/hello/:kuntal

I am trying this function using this url:- 192.168.1.101/hello/:kuntal

我需要将名称的值设为 kuntal 但在函数中我将名称的值设为 :kuntal 所以请告诉我如何删除它:(冒号) 在名称之前.

i need to get value of name as kuntal but in function i am getting value of name as :kuntal so please tell me how can i remove this :(colon) before the name.

是另一种方法.

如果您了解用于制作 REST API 的超薄框架,请给我您的建议.提前致谢.

Please give me your suggestion if you are aware about slim framework to make REST API. Thank you in advance.

推荐答案

试试这个网址:192.168.1.101/hello/kuntal我认为这肯定适用于您的代码.

Try this url: 192.168.1.101/hello/kuntal i think this will definitely work for your code.

更多推荐

使用 REST API 从表中获取数据

本文发布于:2023-10-29 13:02:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539765.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   REST   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!