简体   繁体   English

为什么在 php 中使用 Restful API 而不是 json_encode 函数?

[英]Why to use Restful API instead of json_encode function in php?

I want to create a web application, where i can load data on run time through JavaScript(angularJS), my friend told me to use restful API for the conversion of data from MySQL to JSON format, the thing which is confusing me is that why should I use Restful API, when I can use the simple php function "json_enocode".我想创建一个 Web 应用程序,我可以在其中通过 JavaScript(angularJS)在运行时加载数据,我的朋友告诉我使用 restful API 将数据从 MySQL 格式转换为 JSON 格式,让我感到困惑的是为什么当我可以使用简单的 php 函数“json_enocode”时,我应该使用 Restful API。 What other functionalities and benefits, i get when i use Restful API ?当我使用 Restful API 时,我还能获得哪些其他功能和好处?

Restful API is not data encoding structure. Restful API 不是数据编码结构。 I would suggest you read more about restful API and decide whether you need to create API for you web application or not.我建议您阅读更多有关 restful API 的信息,并决定是否需要为您的 Web 应用程序创建 API。

Either way you'll use json_encode to encode your data to json.无论哪种方式,您都将使用 json_encode 将数据编码为 json。 So, you don't need to create restful API to convert data to json.因此,您不需要创建restful API 来将数据转换为json。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM