Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.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/2/ssis/2.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 如何在angular中发布数据_Php_Angular_Typescript - Fatal编程技术网

Php 如何在angular中发布数据

Php 如何在angular中发布数据,php,angular,typescript,Php,Angular,Typescript,这是我用来发布数据的角度代码 const postData = { "username": "Customer004", "email": "customer004@email.com", "password": "0000252525", "gender": "male", } this.http.post("http://localhost/android/Api.php?apicall=signup",

这是我用来发布数据的角度代码

  const postData = {
        "username": "Customer004",
        "email": "customer004@email.com",
        "password": "0000252525",
        "gender": "male",
    }

    this.http.post("http://localhost/android/Api.php?apicall=signup", postData, options)
        .subscribe(data => {
            console.log(data);
        });
但是当我试图打印响应时,我在后端使用php代码得到null

response['post']=$_POST['username'];
它给了我
null

这是我的php代码。。 我已经硬编码了数据。但是试图打印post请求。它给我空值 这是我的php代码 我的角度代码在这里


在php的后端使用

   $post=json_decode(file_get_contents('php://input'));
   echo $post->username;

它会工作的

请参阅您的浏览器是否正在制作的网络选项卡http post?如果它正在发出
post
请求,请参阅请求中的
payload
,首先使用postman或CURL验证API。确保它工作正常。@Arctezy我与邮递员进行了检查。它工作正常。我认为问题在于使用角度{错误:true,消息:“用户已注册”,post:null}错误:true消息:“用户已注册”post:null@FahadHassan.I在network tab.const postData={“username”:“Customer004”中得到空值,“电子邮件”:customer004@email.com“,”密码“:”000025525“,”性别“:”男性“,}这是传递给如何在后端获取用户名的json。此json是从一个混合应用程序传递给您的php://input. 我从一个客户端发布json数据,这是一个移动应用程序,因为post是php的一个输入,它将完成您正在尝试的操作