|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-02-04 17:10 UTC] andreyra at chtivo dot ru
Description:
------------
I have found strange behaviour with PHP POST/GET arrays. With print_r() command I have see all contents of array, but if I trying to access to values of array directly - I have got errors.
I have test this code with:
php5.1.2
php5.2.0
php5.2-win32-200702041530
Apache2.0.58/win32/php5apache2.dll
Apache2.2.3/win32/php5apache2_2.dll
Apache2.2.4/win32/php5apache2_2.dll
And always I have same results.
In my php.ini:
register_globals = On
register_long_arrays = On
register_argc_argv = On
post_max_size = 512M
Reproduce code:
---------------
<form name="topics" method="post">
<input type="text" name="topic[1]['name']" value="Some text"><br/>
<button onclick="this.form.submit(true);">POST</button>
</form>
<?php
if (!isset($_POST['topic'])){
return false;
};
if (!is_array($_POST['topic'])){
return false;
};
foreach ($_POST['topic'] as $topic_id=>$arr){
print_r($arr);
if (!isset($arr['name'])){
echo "<br/>\r\nERROR! NAME field is not set!\r\n";
continue;
};
echo 'OK.';
};
?>
Expected result:
----------------
OK.
Actual result:
--------------
ERROR! NAME field is not set!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 12:00:02 2025 UTC |
See the difference between: array("name"=>"value") and array("\'name\'"=>"value")