note 53821 deleted from function.serialize by aharvey
| From: | aharvey@php.net | Date: | Tue, 06 Nov 2012 02:07:46 +0000 |
| Subject: | note 53821 deleted from function.serialize by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191758@lists.php.net to get a copy of this message | ||
Note Submitter: abductee _at_ texture _minus_ editor.com
----
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