gpt4 book ai didi

php - file_get_contents ('php://input' )不工作。空 - NULL

转载 作者:行者123 更新时间:2023-12-03 20:54:01 24 4
gpt4 key购买 nike

我在过去的 12 个小时里遇到了这个问题,我在这里阅读了大约 50 篇文章,50 个问题,我无法解决它。我会更精确,我希望其他人也能得到解决方案。

问题:我在 namech**** 有一个托管帐户和一个本地服务器。那里的 Linux 和这里的 Xampp Windows,这只适用于我的本地服务器。

test.php:

<?php
$data = json_decode(file_get_contents("php://input"), true);
var_dump($data);
?>

发布请求是:
POST /test.php HTTP/1.1
Host: myweb.io
Content-Type: application/json
Content-Length: 77

{
"test": "product/created",
"other": "https://google.com/"
}

我使用 REQBIN 来测试 POST 请求。

这是我托管的回复:
HTTP/1.1 200 OK
Date: Sun, 03 May 2020 17:04:33 GMT
Server: Apache
X-Powered-By: PHP/7.4.5
Content-Encoding: gzip
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

NULL

这是使用 XAMPP 在我的本地环境中的正确响应
HTTP/1.1 200 OK
Date: Sun, 03 May 2020 17:15:19 GMT
Server: Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.4.3
X-Powered-By: PHP/7.4.3
Content-Length: 94
Content-Type: text/html; charset=UTF-8

Array
(
[test] => product/created
[other] => https://google.com/
)

我试过的东西:
  • 将 allow_url_fopen 设置为 1 或 0。
  • 降级 PHP 版本(已尝试 7.1、2、3、4)
  • 卸载 SSL 证书
  • PHP.INI 中的数以百万计的东西
  • 删除 htaccess
  • 删除一些 php 模块/扩展
    更新:
  • 该文件是单独的,检查该功能只执行一次
  • 我检查是否没有重定向。 (Htaccess、cPanel 设置)
  • 最佳答案

    信不信由你:
    改变:
    重写规则 ^/%1 [NC,L,R]

    重写规则 ^ %1 [NC,L,R]
    然后回到
    重写规则 ^/%1 [NC,L,R]
    同样地
    RewriteRule ^(.*?)/?$/$1.php [NC,L]

    RewriteRule ^(.*?)/?$ $1.php [NC,L]
    然后回到
    RewriteRule ^(.*?)/?$/$1.php [NC,L]
    看来要解决了!

    关于php - file_get_contents ('php://input' )不工作。空 - NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61578684/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com