用于记录 POST 原始数据的 PHP 脚本 [英] PHP script to log the raw data of POST

查看:20
本文介绍了用于记录 POST 原始数据的 PHP 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 HTTP POST 向我的服务器发送数据.但是在服务器中,我没有收到数据.不知何故,我没有任何方法可以在客户端检查数据(或调试脚本).但是在客户端,我收到了 HTTP 200,这意味着发送了数据.我也可以看到连接和数据发送成功.但是,登录服务器不包含数据(只有字节数).

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 the client side I am getting HTTP 200, meaning 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).

如何记录发送到服务器的原始 POST 数据?

How can I log the raw POST data that was sent to the server?

仅供参考,这里的客户端是一个功能非常有限的嵌入式设备,所以这是一个问题.我无法检查print_r"或回声".

FYI, here the client is an embedded device with very limited capability, so this is a problem. I can not check "print_r" or "echo".

推荐答案

您可以通过以下方式查看 POST 数据内联(非用于生产)的内容:

You can see the content of POST data inline (not for production) with:

print_r($_POST);

或者如果您想查看 POST、GET 和 COOKIE 数据:

Or if you want to see POST, GET and COOKIE data:

print_r($_REQUEST);

如果您需要登录,因为客户端非常有限 - 尝试将 POST 数据输出到文件:

If you need to log, since the client is very limited - try outputting the POST data to a file:

file_put_contents("post.log", print_r($_POST, true));

这篇关于用于记录 POST 原始数据的 PHP 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆