file_get_contents("php://input")在var_dump时显示null


file_get_contents("php://input") showing null when var_dump

file_get_contents("php://input");不工作

$data=$_GET['json']; is working.

我的网址:

http://localhost/demo/plainjson.php?json = {" order_number":"54321","id":"1102","状态":3 " card_no ": " 1234 "}

$data = file_get_contents("php://input");
$json = json_decode($data, true);
var_dump($json);// o/p->Null
print_r($json);// o/p-> nothing
echo $json[2];

如何回显或打印url json数组或值需要帮助。与解释。

allow_url_include可能不会在您的php.ini中设置为true ?这在一些旧的共享主机服务

上很常见。

请参阅这篇堆栈溢出文章以获取潜在的修复。

啊……问题是,你没有张贴任何东西。而是通过查询字符串发送,这样流就没有主体可以检索。所以我的理解是你不能使用流来获取数据

参见PHP.net artitical

"php://input是一个只读流,允许您从请求体中读取原始数据。在POST请求"

"的情况下

更多信息请看这篇文章