Edit report at https://bugs.php.net/bug.php?id=61110&edit=1
ID: 61110
User updated by: tansuanna at gmail dot com
Reported by: tansuanna at gmail dot com
Summary: The same codes output the different results between
ver5.3.8 & ver5.3.10
Status: Not a bug
Type: Bug
Package: Class/Object related
Operating System: CentOS 5.5
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
how to get the value of $a[2]?
var_dump($a['2']); //NULL
Previous Comments:
------------------------------------------------------------------------
[2012-02-17 01:54:44] tansuanna at gmail dot com
but i cant get the values:
var_dump(isset($a[2])); // false
var_dump(isset($a['2'])); // false
$id = strval(2);
var_dump(isset($a[$id])); // false
------------------------------------------------------------------------
[2012-02-17 00:53:13] [email protected]
This came about as a result of the fix for bug #55798 in 5.3.9. At some point,
we've just got to pick a behaviour and stick with it: the new behaviour at
least
makes the unserialised properties accessible, which is better than the old.
------------------------------------------------------------------------
[2012-02-16 17:58:49] tansuanna at gmail dot com
Description:
------------
The same codes output the different results between ver5.3.8 & ver5.3.10:
<?php
$a = serialize((object)array(
â1â² => âaaaâ,
â2â² => âbbbâ,
â3â² => âcccâ,
));
$a = (array)unserialize($a);
$a[1] = âdddâ;
var_dump($a);
?>
// results before ver5.3.8ï¼
array(3) {
[1]=>
string(3) âdddâ
[2]=>
string(3) âbbbâ
[3]=>
string(3) âcccâ
}
// results in ver5.3.10ï¼
array(4) {
["1"]=>
string(3) âaaaâ
["2"]=>
string(3) âbbbâ
["3"]=>
string(3) âcccâ
[1]=>
string(3) âdddâ
}
Test script:
---------------
<?php
$a = serialize((object)array(
â1â² => âaaaâ,
â2â² => âbbbâ,
â3â² => âcccâ,
));
$a = (array)unserialize($a);
$a[1] = âdddâ;
var_dump($a);
?>
Expected result:
----------------
output same results in their versions:
array(3) {
[1]=>
string(3) âdddâ
[2]=>
string(3) âbbbâ
[3]=>
string(3) âcccâ
}
Actual result:
--------------
// results before ver5.3.8ï¼
array(3) {
[1]=>
string(3) âdddâ
[2]=>
string(3) âbbbâ
[3]=>
string(3) âcccâ
}
// results in ver5.3.10ï¼
array(4) {
["1"]=>
string(3) âaaaâ
["2"]=>
string(3) âbbbâ
["3"]=>
string(3) âcccâ
[1]=>
string(3) âdddâ
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61110&edit=1