#31688 [NEW]: Assignment by reference to a static variable doesn't work properly
| From: | mike at somosis dot co dot uk | Date: | Tue, 25 Jan 2005 14:04:38 +0000 |
| Subject: | #31688 [NEW]: Assignment by reference to a static variable doesn't work properly | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-72782@lists.php.net to get a copy of this message | ||
From: mike at somosis dot co dot uk
Operating system: FreeBSD (experienced on others)
PHP version: 4.3.10
PHP Bug Type: Variables related
Bug description: Assignment by reference to a static variable doesn't work properly
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 bug report at http://bugs.php.net/?id=31688&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31688&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31688&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31688&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31688&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31688&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31688&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31688&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31688&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31688&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31688&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31688&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31688&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31688&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31688&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31688&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31688&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31688&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31688&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31688&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31688&r=mysqlcfg