ID: 27712
Updated by: [EMAIL PROTECTED]
Reported By: hannes at phpug dot ch
-Status: Open
+Status: Bogus
Bug Type: Zend Engine 2 problem
-Operating System: Debian GNU/Linux
+Operating System: *
-PHP Version: 5.0.0RC1
+PHP Version: 5CVS-2004-04-07
New Comment:
<?php
error_reporting(E_ALL);
$nam = array ("0" => "hubert", "1" => "waldo");
$ser = serialize ($nam);
echo $ser, "\n";
$unser = unserialize ($ser);
var_export($unser);
?>
Using that script, I can NOT get such serialized string as you did.
Note: There was some bug in this earlier but nowadays serialize() works
fine..
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