PHP $ _POST数组变量被截断 [英] PHP $_POST array variables are truncated
问题描述
我使用PHP 5.3.8与Apache 2.0。我也使用的Symfony 2但这不是该脚本失败。我有一个数组变量形式:
I am using PHP 5.3.8 with Apache 2.0. I am also using Symfony 2 but that's not where the script is failing. I have a form with array variables:
<form action="/app_dev.php/admin/position/create" method="post">
<input type="text" id="po_name" name="po[name]" required="required" maxlength="50">
<input type="text" id="po_role" name="po[role]" required="required" maxlength="20">
</form>
直接在app_dev.php文件(从问题排除Symfony的)我做的:
Directly in the app_dev.php file (to rule out Symfony from the problem) I do:
echo file_get_contents("php://input"); // outputs: po%5Bname%5D=Developer&po%5Brole%5D=ROLE_USER
var_dump($_POST); // outputs: array(1) { ["po"]=> array(1) { ["name"]=> string(9) "Developer" } }
die();
它基本上只保留第一个变量数组中为止。如果我改变变量的名称由宝[作用]为BA [作用]然后$ _ POST输出:
Basically it keeps only the first variable in the array. If I change the name of the variable from po[role] to ba[role] then $_POST outputs:
array(1) {
["po"]=> array(1) { ["name"]=> string(9) "Developer" },
["ba"]=> array(1) { ["role"]=> string(9) "ROLE_USER" }
}
我发现的典型问题,这些问题可能导致此问题是由于以下php.ini配置,我也给你什么是我的价值观:
Typical problems I have found that can cause this issue are due to the following php.ini configuration, I also give you what are my values:
max_execution_time = 30
max_input_time = 60
max_input_nesting_level = 64
max_input_vars = 1000
post_max_size = 8M
upload_max_filesize = 2M
memory_limit = 128M
这些值似乎是合理的,我认为不会引起问题,但不能100%肯定。
These values seems reasonable and I think don't cause the problem, but cannot be 100% sure.
我的没有安装了Suhosin 的,因为我读过它可能会导致类似的问题了。
I do not have suhosin installed as I've read it can cause similar problems too.
这也类似于<一个href=\"http://stackoverflow.com/questions/5077969/php-some-post-values-missing-but-are-$p$psent-in-php-input\">this问题但鉴于需要我重写HttpFoundation的Symfony组件的解决方案。
It is also similar to this problem but the solution given would require me to rewrite the HttpFoundation Symfony component.
此外,我不希望有重写表单变量不和阵列(的例如的PO [名]以PO_NAME)作为形式是由Symfony的自动生成,这似乎是一个基本的功能,PHP应该能够处理
Also I don't want to have to rewrite the form variable without and array (e.g. po[name] to po_name) as the form are automatically generated by Symfony and this seems to be a basic feature that PHP should be able to handle.
是否有人对这个问题的任何想法?
Does someone have any idea about this problem ?
PS:这类似于在<一个描述的问题href=\"http://stackoverflow.com/questions/10026198/passed-arrays-lose-all-but-first-element\">here.再加上问题发生在同一个版本的Suse(SUSE Linux企业服务器11)。
PS: this is similar to the problem described in here. Plus the problem happens on the same version of Suse (SUSE Linux Enterprise Server 11 ).
推荐答案
我们终于决定更新我们的PHP版本到最新的版本(5.3.15),现在工作得很好。因此,这是肯定的一个问题,这5.3.8,至少版本中,我们了。
We finally decided to update our version of PHP to a more recent version (5.3.15) and it works fine now. So this was for sure a problem with this 5.3.8, at least the version we had.
这篇关于PHP $ _POST数组变量被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!