Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.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 如何在web服务中传递值_Php_Web Services_Get - Fatal编程技术网

Php 如何在web服务中传递值

Php 如何在web服务中传递值,php,web-services,get,Php,Web Services,Get,我已经创建了一个示例web服务,这将返回一个Json数据。看起来像下面 现在,我希望使用用户名进行验证,用户名应该取值并相应地更改响应 像这样的 如何添加此验证并相应地更改响应。谢谢你的帮助,谢谢 你可以这样做 <?php header('Content-type: application/json'); if($_GET["user"]) { $user = $_GET["user"];

我已经创建了一个示例web服务,这将返回一个Json数据。看起来像下面

现在,我希望使用用户名进行验证,用户名应该取值并相应地更改响应

像这样的


如何添加此验证并相应地更改响应。谢谢你的帮助,谢谢

你可以这样做

<?php
        header('Content-type: application/json');
        if($_GET["user"])
        {
             $user = $_GET["user"];
             // write your code that will use the user name
        }
        else
        {
            // return error or anything said the user is missing
        }

?>

{
    result: [
        {
            say: "omg",
            dsay: "D omg",
        },{
            say: "bla",
            dsay: "D bla",
        },
    ]
}
<?php
        header('Content-type: application/json');
        if($_GET["user"])
        {
             $user = $_GET["user"];
             // write your code that will use the user name
        }
        else
        {
            // return error or anything said the user is missing
        }

?>