为什么我无法使用$ _POST获取数据

时间:2018-01-26 11:36:56

标签: php

我正在开发一个php数据接口。但我无法获取数据。

A.php

$options = [
       'http' => [
            'method'  => 'POST',
            'content' => $data,
            'header'  => "Content-Type: application/json\r\n" .
                         "Accept: application/json\r\n"
        ]
    ];
    $context  = stream_context_create( $options );
    $result   = file_get_contents('B.php', false, $context );
    echo $result; //Output: I have recvieve it. // It's proves that the url is right.

B.php

$data = $_POST; // The $data is empty. Why??? It can't get the data
echo 'I have recvieve it';

0 个答案:

没有答案