Edit report at http://bugs.php.net/bug.php?id=52286&edit=1
ID: 52286
User updated by: paydorrr at gmail dot com
Reported by: paydorrr at gmail dot com
Summary: New lines in serialize()
-Status: Open
+Status: Closed
Type: Bug
Package: Arrays related
Operating System: Ubuntu
PHP Version: 5.3.2
New Comment:
My example actually has an error in it and works perfectly fine.
Actually I had the problem as I posted the string to serialize to the
test page.
I will try to reproduce that and post it again.
Previous Comments:
------------------------------------------------------------------------
[2010-07-08 11:39:44] paydorrr at gmail dot com
Description:
------------
I just hit an unexpected problem:
serialize() counts new lines as characters, although in the serialized
output, those characters do not appear. The character count of the
serialized string is then wrong and unserialize() ist not possible.
Test script:
---------------
$textOne = "String to serialize with
multiple
lines!";
$array = Array(0 => $textOne);
echo serialize($array);
/*
This will print out:
a:1:{i:0;s:42:"String to serialize with multiple lines!";}
The problem with that is, that the serialized String is actually 40, not
42 characters long. Because of that, you cannot unserialize the whole
serialized Array. */
Expected result:
----------------
a:1:{i:0;s:40:"String to serialize with multiple lines!";}
Actual result:
--------------
a:1:{i:0;s:42:"String to serialize with multiple lines!";}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52286&edit=1