Setting array element with that same array produces inconsistent results
| Bug #46649 | Setting array element with that same array produces inconsistent results | ||||
|---|---|---|---|---|---|
| Submitted: | 2008-11-22 23:08 UTC | Modified: | 2008-11-23 20:39 UTC | ||
| From: | binarysurgeon at gmail dot com | Assigned: | |||
| Status: | Closed | Package: | *General Issues | ||
| PHP Version: | 5.2.6 | OS: | Linux 2.6 | ||
| Private report: | No | CVE-ID: | None | ||
[2008-11-22 23:08 UTC] binarysurgeon at gmail dot com
Description:
------------
When setting an a particular array element to the array itself, results are different when it's inside a function vs outside the function.
Reproduce code:
---------------
function func()
{
$a[1] = '1';
$a[0] = $a;
var_dump($a);
}
func();
$a[1] = '1';
$a[0] = $a;
var_dump($a);
Expected result:
----------------
I'm not sure what to expect but at the vary least, the results should be consistent. Results were consistent in 5.2.1.
array(2) {
[1]=>
string(1) "1"
[0]=>
array(1) {
[1]=>
string(1) "1"
}
}
array(2) {
[1]=>
string(1) "1"
[0]=>
array(1) {
[1]=>
string(1) "1"
}
}
Actual result:
--------------
array(2) {
[1]=>
string(1) "1"
[0]=>
NULL
}
array(2) {
[1]=>
string(1) "1"
[0]=>
array(1) {
[1]=>
string(1) "1"
}
}
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2008-11-23 20:39 UTC] lbarnaud@php.net