PHP设置? PHP未收到POST数据 [英] PHP Settings? PHP not receiving POST data

查看:81
本文介绍了PHP设置? PHP未收到POST数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Java应用程序发送.php文件POST数据. .php文件不接受POST数据. file_get_contents('php://input')为空,$ _ POST为空.我知道问题不在于.php文件或Java应用程序,因为我使用其他主机对其进行了测试,并且可以正常工作.我缺少php.ini中的设置还是需要更改的设置?

I’m sending a .php file POST data from a java application. The .php file is not accepting the POST data. file_get_contents(‘php://input’) is empty and $_POST is empty. I know the problem isn’t with the .php file or java application because I tested it using a different host and it worked. Is there a setting in php.ini I’m missing or a setting I need to change?

推荐答案

如果Content-Type为空或在HTTP消息中无法识别,则PHP $ _POST数组为空.如果您无法发送Content-Type,则可以将其添加到您的PHP中:

If the Content-Type is empty or not recognized in the HTTP message then the PHP $_POST array is empty. If you cannot send the Content-Type you can add this to your PHP:

if(empty($_SERVER['CONTENT_TYPE']))
{ 
 $_SERVER['CONTENT_TYPE'] = "application/x-www-form-urlencoded"; 
}

您还可以检查php.ini中的设置是否正确

You can also check if you have the correct settings in your php.ini

; Maximum size of POST data that PHP will accept.
post_max_size = 8M

如果post_max_size为0,则PHP不会填充$ _POST.

If post_max_size is 0, PHP will not populate $_POST.

variables_order = "EGPCS"

如果那里没有P,则也不会设置$ _POST.

If you do not have P in there, $_POST will not be set either.

这篇关于PHP设置? PHP未收到POST数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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