Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP';s echo作为web服务_Php_Web Services_Echo - Fatal编程技术网

使用PHP';s echo作为web服务

使用PHP';s echo作为web服务,php,web-services,echo,Php,Web Services,Echo,创建restful web服务的工作量太大了。 为什么我们不能创建一个简单的php页面来接收请求并简单地回显JSON字符串呢。 例如: <?php $action = $_POST['action']; if (action == "users") { //get all users from DB and echo a JSON string } else if (action = "ads") {

创建restful web服务的工作量太大了。 为什么我们不能创建一个简单的php页面来接收请求并简单地回显JSON字符串呢。 例如:

<?php
     $action = $_POST['action'];
     if (action == "users")
     {
          //get all users from DB and echo a JSON string
     }
     else if (action = "ads")
     {
          //get all ads from DB and echo a JSON string
     }
     //etc ect
?>


这是restful服务的一部分。它是只读的。如果您不需要执行任何写入操作,那么这种方法没有错。

这是restful服务的一部分。它是只读的。如果您不需要执行任何写入操作,那么这种方法没有错。

您可以。但是如果要求是“创建一个restful Web服务”,那么你可能会与你的老板发生冲突,除非你有一个很好的理由来解释为什么你会采用这种方法:)

你可以。但是如果要求是“创建一个restful Web服务”,那么你很可能会与你的老板发生冲突,除非你有一个很好的理由来解释为什么你会采用这种方法:)

问题是什么?为什么我们不能?我们可以。问题是什么?为什么我们不能?我们可以。