#31688 [Opn->Bgs]: Assignment by reference to a static variable doesn't work properly
| From: | sniper@php.net | Date: | Tue, 25 Jan 2005 14:22:37 +0000 |
| Subject: | #31688 [Opn->Bgs]: Assignment by reference to a static variable doesn't work properly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-72786@lists.php.net to get a copy of this message | ||
ID: 31688
Updated by: sniper@php.net
Reported By: mike at somosis dot co dot uk
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: FreeBSD (experienced on others)
PHP Version: 4.3.10
New Comment:
RTFM:
http://www.php.net/variables.scope
"..assigning a reference to a static variable, it's not remembered.."
Last example in the page.
Previous Comments:
------------------------------------------------------------------------
[2005-01-25 15:04:38] mike at somosis dot co dot uk
Description:
------------
Static variables that are assigned to by reference in a function lose
the assignment when the function terminates.
Reproduce code:
---------------
function a(&$v, $s) {
static $x;
if($s)
$x =& $v;
print("\$x in a: {$x}<br />\n");
}
$c = 1;
a($c, true);
a($c, false);
Expected result:
----------------
$x in a: 1
$x in a: 1
Actual result:
--------------
$x in a: 1
$x in a:
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31688&edit=1