php 用于记录POST原始数据的php脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3718307/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
php script to log the raw data of POST
提问by Morison
I am sending data using HTTP POST to my server. But in the server, I am not receiving the data. And somehow I don't have any way to check the data (or debug script) on client side. But on client side I am getting HTTP 200, means data is sent. Also I can see the connection and data sending was successful. However log in the server doesn't contain the data (only the number of bytes).
我正在使用 HTTP POST 向我的服务器发送数据。但是在服务器中,我没有收到数据。不知何故,我没有任何方法来检查客户端的数据(或调试脚本)。但在客户端,我收到 HTTP 200,意味着数据已发送。我也可以看到连接和数据发送成功。但是登录服务器不包含数据(只有字节数)。
How can I log the raw POST data that was sent to the server?
如何记录发送到服务器的原始 POST 数据?
FYI, here client is an embedded device with very limited capability. SO, is this problem. So, I can not check "print_r" or "echo"
仅供参考,这里的客户端是一个功能非常有限的嵌入式设备。SO,是不是这个问题。所以,我无法检查“print_r”或“echo”
回答by Rudu
You can see the content of post data inline (not for production) with:
您可以通过以下方式查看内联发布数据的内容(不适用于生产):
print_r($_POST);
Or if you want to see POST, GET and COOKIE data:
或者,如果您想查看 POST、GET 和 COOKIE 数据:
print_r($_REQUEST);
If you need to log, since the client is very limited - try outputting the POST data to a file:
如果您需要登录,因为客户端非常有限 - 尝试将 POST 数据输出到文件:
file_put_contents("post.log", print_r($_POST, true));
回答by Sjoerd
Write post data to a file:
将发布数据写入文件:
file_put_contents('/tmp/postdata.txt', var_export($_POST, true));
回答by Sjoerd
You can try sniffing the HTTP session.
您可以尝试嗅探 HTTP 会话。
回答by Aviatrix
try using var_dump($_POST['name-of-field'])
or var_dump($_POST)
尝试使用 var_dump($_POST['name-of-field'])
或var_dump($_POST)
updated:// and browse the source of the page and look for an array
updated:// 并浏览页面的源代码并查找数组