在 php 中创建一个基本的 Web 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6507726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:35:38  来源:igfitidea点击:

Creating a basic web services in php

phpweb-services

提问by sandy

I want to find how to create a simple web service using PHP. I am new to web service. Is there any tutorial so I can learn it from the start. Thanks all.

我想了解如何使用 PHP 创建一个简单的 Web 服务。我是网络服务的新手。有没有教程可以让我从头开始学习。谢谢大家。

I want to host this webservice so I can use this web service in android app development I own my hosting space.

我想托管此网络服务,以便我可以在我拥有托管空间的 android 应用程序开发中使用此网络服务。

回答by Quentin

There is nothing particularly special about a web service when compared to any other kind of site. The major difference is that output is generally in a format other than HTML, these days it is usually JSON, which has its own section in the PHP manual

与任何其他类型的站点相比,Web 服务并没有什么特别之处。主要区别在于输出通常采用 HTML 以外的格式,现在通常是JSON,在 PHP 手册中有自己的部分

Aside from that it is just a matter of having sensible URIs, which may take sensible query strings or post data, and may require some kind of authentication (just like any other site).

除此之外,它只是拥有合理的 URI 的问题,它可能需要合理的查询字符串或发布数据,并且可能需要某种身份验证(就像任何其他站点一样)。