|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-03-02 22:26 UTC] mi+php at aldan dot algebra dot com
Description: ------------ A serializing string "foo" produces an intuitive result 's:3:"foo"' and unserialize() properly decodes that back. It would be useful, however, if the unserialize function could handle (even if less efficiently) cases, where the string-length is missing or even specified incorrectly. Currently any such mismatches result in empty output from the function, even though `s:"foo"' or `s::"foo"' or even `s:4:"foo"' is no harder to understand. The feature would be of help to those of us, who need to a massive search/replace in the dump of serialized objects. Test script: --------------- <? $s1 = "s:7:\"1234567\""; $s2 = "s:6:\"1234567\""; $s3 = "s:8:\"1234567\""; $s4 = "s::\"1234567\""; print "S1: >" . unserialize($s1) . "<\n"; print "S2: >" . unserialize($s2) . "<\n"; print "S3: >" . unserialize($s3) . "<\n"; print "S4: >" . unserialize($s4) . "<\n"; ?> Expected result: ---------------- S1: >1234567< S2: >1234567< S3: >1234567< S4: >1234567< Actual result: -------------- S1: >1234567< S2: >< S3: >< S4: >< PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
It depends on the lengths because the strings aren't escaped. serialize('"') = s:1:""";