請考慮下面這個簡單的測試套件:多維數組後PHP 5.4.6
<?php
$data = file_get_contents('php://input');
echo '<pre>';
echo 'raw: <br/>';
print_r($data);
echo '<br/>$_POST: <br/>';
print_r($_POST);
echo '
<form name="form1" method="post" type="application/x-www-form-urlencoded" action="postTest.php"/>
<input type="text" name="my1[]" value="1" />
<input type="text" name="my1[]" value="2" />
<input type="text" name="my3" value="3 "/>
<input type="submit" />
</form>
預期這將返回在大多數服務器上運行PHP5 +
raw:
my1%5B%5D=1&my1%5B%5D=2&my3=3+
$_POST:
Array
(
[my1] => Array
(
[0] => 1
[1] => 2
)
[my3] => 3
)
。但是我的本地系統與Ubuntu 12.10的Apache 2.2.22,PHP 5.4.6,現場tr_TR.UTF-8,它將返回
raw:
my1%5B%5D=1&my1%5B%5D=2&my3=3+
$_POST:
Array
(
[my3] => 3
)
其中MY1陣列消失。請注意,$ _POST ['my3']仍然存在,我不會遇到任何其他非數組$ _POST數據的問題,我仍然可以看到m1存在於原始數據中。 這真是奇怪的行爲。通常會導致這個問題的是什麼?
只是猜測(可能會浪費你多餘的一分鐘),爲什麼'+'會在'raw:'數據的末尾出現。你能否從'my3'字段名稱的'value'中刪除空格。 – MaNKuR