note 95938 added to reserved.variables.post
| From: | toader_alexandru at yahoo dot com | Date: | Fri, 29 Jan 2010 15:06:54 +0000 |
| Subject: | note 95938 added to reserved.variables.post | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165491@lists.php.net to get a copy of this message | ||
When you have a form with some radio:
<?php
<form method='post'>
<input type='radio' name='55' value='1' >
<input type='radio' name='55' value='2' >
<input type='radio' name='55' value='3' >
<input type='radio' name='55' value='4' >
<input type='submit' value='ok' >
</form>
?>
if the name of the radio is a number will be returned by $_POST as INT!!!! not string as the manual
says
if the name of the radio is 'test' will be of course returned ad string.
So your post array will look like this:
<?php
array
167302 => string '167308' (length=6)
167314 => string '167344' (length=6)
167347 => string '5867521' (length=7)
'3754952706' => string '3754952706' (length=10)
'3744466946' => string '3744466946' (length=10)
'3740271617' => string '3740271617' (length=10)
'3749709826' => string '3749709826' (length=10)
'3749708801' => string '1' (length=1)
'meta' =>
array
'hasJavascript' => string '0' (length=1)
'timeToComplete' => string '1264769572.6144' (length=15)
'Submit' => string 'Next' (length=4)
?>
Note the first 3 keys are int not string
This could affect you if you do some operations for example if you do an array_merge with your post
values:
<?php
$arr1 = array(
167302 => '167308',
167314 => '167344',
167347 => '5867521',
'3754952706' => '3754952706',
'3744466946' => '3744466946',
'3740271617' => '3740271617',
'3749709826' => '3749709826',
'3749708801' => '1'
);
$arr2 = array(
'meta' =>
array (
'hasJavascript' => '0',
'timeToComplete' => '1264769572.6144'
)
);
?>
if you do :
<?php
$values = array_merge($arr1, $arr2);//this is done by zend in $form->getValues()
?>
guess what will be the result? your numeric keys will be reindexed starting from 0.
and your post values will look like this:
<?php
0 => string '167308' (length=6)
1 => string '167344' (length=6)
2 => string '5867521' (length=7)
'3754952706' => string '3754952706' (length=10)
'3744466946' => string '3744466946' (length=10)
'3740271617' => string '3740271617' (length=10)
'3749709826' => string '3749709826' (length=10)
'3749708801' => string '1' (length=1)
'meta' =>
array
'hasJavascript' => string '0' (length=1)
'timeToComplete' => string '1264769572.6144' (length=15)
?>
----
Server IP: 69.147.83.197
Probable Submitter: 132.185.240.121
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.post.php
Edit -- https://master.php.net/note/edit/95938
Del: integrated -- https://master.php.net/note/delete/95938/integrated
Del: useless -- https://master.php.net/note/delete/95938/useless
Del: bad code -- https://master.php.net/note/delete/95938/bad+code
Del: spam -- https://master.php.net/note/delete/95938/spam
Del: non-english -- https://master.php.net/note/delete/95938/non-english
Del: in docs -- https://master.php.net/note/delete/95938/in+docs
Del: other reasons-- https://master.php.net/note/delete/95938
Reject -- https://master.php.net/note/reject/95938
Search -- https://master.php.net/manage/user-notes.php