note 53821 added to function.serialize
| From: | abductee_at_texture_minus_editor dot com at osu1 dot php dot net | Date: | Tue, 14 Jun 2005 11:44:15 +0000 |
| Subject: | note 53821 added to function.serialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90408@lists.php.net to get a copy of this message | ||
wiart at yahoo dot com wrote:
>As you can see, the original array :
>$arr["20041001103319"] = "test"
>
>after serialize/unserialize is:
>$arr[683700183] = "test"
yepp, and i can explain it.
the internal compiler of php does not hit anys rule wich foces him to make that number a string
during serialisation. since it becomes an integer and php supports 32bit interger not arbitary
bitwidth this is what happens:
"20041001103319"
equals hexadecimal:
0x123A28C06FD7h
if you cut away the frontpart cutting down to 32bis,
you get:
0x28C06FD7h
wich equals 683700183.
of, for those of you who speak binary:
20041001103319 =
100100011101000101000110000000110111111010111bin
----cut-away----00101000110000000110111111010111bin
=683700183
so, what can you do to prevent stuff like this?
eihter use only numbers between 0..9999999999
or force strings, best way ist to add a character
like
foo["c2342303"]
cheers, abductee
----
Manual Page -- http://www.php.net/manual/en/function.serialize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53821
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53821&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53821&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53821&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53821&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53821&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53821&report=yes
Search -- http://master.php.net/manage/user-notes.php