#27712 [Com]: unserialize / Array access

From: Date: Sun, 04 Apr 2004 06:42:22 +0000
Subject: #27712 [Com]: unserialize / Array access
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-57475@lists.php.net to get a copy of this message
ID: 27712 Comment by: cardoe at cardoe dot com Reported By: hannes at phpug dot ch Status: Open Bug Type: Zend Engine 2 problem Operating System: Debian GNU/Linux PHP Version: 5.0.0RC1 New Comment: I don't know if this warrents a seperate bug report but I'm using PHP 4.3.4 and PHP 5.0.0RC1 and I'm having serialize()/unserialize() issues between the two as well. Data that's serialized in PHP5 is not unserialize()able in PHP4. However the data is unserialize()able in PHP5. If I serialize() data in PHP4, I can unserialize it in PHP5. Here's a snip of a sample serialized data. O:11:"Foreclosure":26:{s:4:"name";a:1:{i:0;r:73;} The problem is on the r in r:73. I don't know what r stands for. Previous Comments: ------------------------------------------------------------------------ [2004-03-26 05:38:54] hannes at phpug dot ch Description: ------------ Unserialize works perfectly and produces an array with like array("0" => "foo"). The same serialized string gets unserialized differently in PHP4, there it's array(0 => "foo"). I cannot access the content of the PHP5 result, because it seems that my lookup for "1"(string) gets converted to one for 1 (int). Which fails. Tested with: -PHP 4.3.5RC2-dev (cli) (built: Jan 15 2004 16:58:31) -PHP 5.0.0RC2-dev (cli) (built: Mar 21 2004 17:58:48) I'm not sure if this is really something that needs to be fixed, unserialize works correctly, but not as expected. Reproduce code: --------------- <?php error_reporting(E_ALL); $serializedNames = 'a:2:{s:1:"0";s:6:"hubert";s:1:"1";s:5:"waldo";}'; $names = unserialize($serializedNames); var_export($names); //works, but... /* php5: array ( '0' => 'hubert', php4: array ( 0 => 'hubert', .. print($names["1"]); // php5: doesn't work. php4: works; print($names[1]); // php5: doesn't work php4: works; ?> Expected result: ---------------- array ( 0 => 'hubert', 1 => 'waldo', )waldowaldo Actual result: -------------- array ( '0' => 'hubert', '1' => 'waldo', ) PHP Notice: Undefined index: 1 in .... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27712&edit=1

« previous php.bugs (#57475) next »