I can#39;t read my POST HTTP request#39;s body with PHP !(我无法使用 PHP 读取我的 POST HTTP 请求正文!)
问题描述
我从未使用过 PHP,但现在,我需要编写一个 PHP 文件,在日志文件中显示 POST HTTP 请求正文的内容.
我了解到您可以通过 _POST 数组访问正文的变量.不幸的是,它似乎是空的,尽管我很确定我的 HTTP 请求正文中有内容!
我应该使用什么来 100% 确定我的 HTTP 正文的内容?
谢谢.
$post_body = file_get_contents('php://input');
<块引用>
php://input
允许您读取原始 POST 数据.它是 $HTTP_RAW_POST_DATA
的内存密集型替代方案,并且不需要任何特殊的 php.ini 指令.php://input
不适用于 enctype="multipart/form-data".
(来源:http://php.net/wrappers.php)上>
I've never used PHP but right now, I need to write a PHP file that displays in a log file the content of the body of a POST HTTP request.
I've read that you can access variables of the body via the _POST array. Unfortunately, it seems to be empty, although I'm pretty sure there is stuff in my HTTP request's body !
What should I use to be 100% sure of the content of my HTTP body ?
Thanks.
$post_body = file_get_contents('php://input');
php://input
allows you to read raw POST data. It is a less memory intensive alternative to$HTTP_RAW_POST_DATA
and does not need any special php.ini directives.php://input
is not available with enctype="multipart/form-data".
(Source: http://php.net/wrappers.php)
这篇关于我无法使用 PHP 读取我的 POST HTTP 请求正文!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我无法使用 PHP 读取我的 POST HTTP 请求正文!


基础教程推荐
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- HTTP 与 FTP 上传 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- 使用 PDO 转义列名 2021-01-01