|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-11-28 08:32 UTC] lenar at vision dot ee
Consider following simple script. It's pretty obvious that serialize() does not work correctly (at least not as expected). <?php $x = new stdClass(); $x->x =& $x; $s = serialize($x) . "\n"; echo "test on original: "; // OK $x->a = "str"; echo $x->x->a . "\n"; $o = unserialize($s); echo "test on unserialized object: "; // not OK $o->a = "str"; echo $o->x->a . "\n"; ?> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 09:00:01 2025 UTC |
I dont' agree. Circular refferences can happen with objects (using refferences). Sometimes they are intentional. And serialize() doesn't completely ignore this. Because it spits out: O:8:"stdClass":1:{s:1:"x";O:8:"stdClass":1:{s:1:"x";R:2;}} so it knows about circular refferences. Now is there any reason why it doesn't generate instead something like this: O:8:"stdClass":1:{s:1:"x";R:1;} I would understand if it completely ignores circular references, but it doesn't. It just misbehaves.