Bug #73169 [Opn]: Variable becames reference
| From: | yohgaki@php.net | Date: | Sun, 25 Sep 2016 19:21:44 +0000 |
| Subject: | Bug #73169 [Opn]: Variable becames reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204255@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73169&edit=1
ID: 73169
Updated by: yohgaki@php.net
Reported by: kilobyte at freemail dot hu
Summary: Variable becames reference
Status: Open
Type: Bug
Package: *General Issues
-Operating System: Windows 7
+Operating System: Irrelevant
-PHP Version: 5.6Git-2016-09-25 (snap)
+PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
https://3v4l.org/ZLToT
All versions do the same. HHVM seems to have problem with this.
Previous Comments:
------------------------------------------------------------------------
[2016-09-25 16:57:23] kilobyte at freemail dot hu
Description:
------------
the code:
class CC
{
private static $bt;
public function run(&$a)
{
self::$bt[] = debug_backtrace();
$a = 222;
}
}
function n(&$a)
{
(new CC())->run($a);
}
$a = [
'a' => 1,
'b' => 2,
'c' => 3
];
n($a['b']);
echo '<pre>';
var_dump($a);
--------------------
this generates the following:
array(3) {
["a"]=>
int(1)
["b"]=>
&int(222)
["c"]=>
int(3)
}
there is a "reference &" signal at "b". If I remove this line:
"self::$bt[] = debug_backtrace();" its gone, it will work right, but why do this variable
goes reference?
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73169&edit=1