note 69117 added to types.comparisons
| From: | omit at osu1 dot php dot net | Date: | Wed, 23 Aug 2006 18:32:18 +0000 |
| Subject: | note 69117 added to types.comparisons | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116235@lists.php.net to get a copy of this message | ||
the manual said "HTML Forms do not pass integers, floats, or booleans; they pass strings"
while this is true, php will sometimes change the type to either type array, or possibly type
integer(no, not a numeric string) if it was used as an array key. php seems to do this when it
parses the request data into the predefined variable arrays.
example:
<input type="text" name="foo[5]">
<input type="text" name="foo[7]">
now obviously the browser will send those names as a string. but php will change thier type.
<?php
// $_POST['foo'] is an array
var_dump($_POST['foo']);
foreach ($_POST['foo'] as $key => $val) {
// the keys 5 and 7 will be type integer
var_dump($key);
}
?>
because of this, its also a good idea to check the types of your variables.
----
Server IP: 64.71.164.2
Probable Submitter: 64.121.72.103
----
X-Spam-Status: No, hits=4.0 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_20_30,HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/types.comparisons.php
Edit -- https://master.php.net/note/edit/69117
Del: integrated -- https://master.php.net/note/delete/69117/integrated
Del: useless -- https://master.php.net/note/delete/69117/useless
Del: bad code -- https://master.php.net/note/delete/69117/bad+code
Del: spam -- https://master.php.net/note/delete/69117/spam
Del: non-english -- https://master.php.net/note/delete/69117/non-english
Del: in docs -- https://master.php.net/note/delete/69117/in+docs
Del: other reasons-- https://master.php.net/note/delete/69117
Reject -- https://master.php.net/note/reject/69117
Search -- https://master.php.net/manage/user-notes.php