|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-09-28 14:13 UTC] cataphract@php.net
-Summary: Type casting problem
+Summary: serialize followed by unserialize with
numeric object prop. gives integer prop.
-Assigned To:
+Assigned To: cataphract
[2011-09-28 14:47 UTC] cataphract@php.net
[2011-09-28 14:47 UTC] cataphract@php.net
-Status: Assigned
+Status: Closed
[2011-09-28 14:47 UTC] cataphract@php.net
[2012-04-18 09:48 UTC] laruence@php.net
[2012-07-24 23:39 UTC] rasmus@php.net
[2013-11-17 09:36 UTC] laruence@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 20:00:01 2025 UTC |
Description: ------------ Hi there! I am having a standard class using numeric keys as properties which works fine in general. The numeric keys are currently Strings. After serializing and unserializing the class, the properties will be converted to Integers which makes them unaccessible. Have a look at the code example below. Regards Lukas Test script: --------------- <?php $a = new stdClass(); $a->{0} = 'X'; $a->{1} = 'Y'; var_dump($a); echo "\n0:", $a->{0}, "\n1:", $a->{1}, "\n\n"; $b = unserialize(serialize($a)); var_dump($b); echo "\n0:", $b->{0}, "\n1:", $b->{1}, "\n\n"; ?> Expected result: ---------------- object(stdClass)#2 (2) { ["0"]=> string(1) "X" ["1"]=> string(1) "Y" } Actual result: -------------- object(stdClass)#2 (2) { [0]=> string(1) "X" [1]=> string(1) "Y" }