Bug #69784 [NEW]: bad variable reference
From: artur at salonstron dot pl
Operating system: irrelevant
PHP version: 5.6.9
Package: Variables related
Bug Type: Bug
Bug description:bad variable reference
Description:
------------
In the example below, the variable $d is assigned a reference to a local
variable $a (in function test) despite the fact that variable was not
returns by reference.
To fix this, you must either before returning the $a use the reset(), or
inside test() use another variable.
Test script:
---------------
<?php
$a = array (
1=>"a",
2=>"b",
3=>"c"
);
$d = test($a);
echo "d:<br />";
while(list($key, $val)=each($d)) {
echo $val." ";
}
function test($a) {
while(list($key, $val)=each($a)) {
$a[$key] = $val . "t3";
}
return $a;
}
Expected result:
----------------
d:
at3 bt3 ct3
Actual result:
--------------
d:
--
Edit bug report at https://bugs.php.net/bug.php?id=69784&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69784&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69784&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69784&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69784&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69784&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69784&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69784&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69784&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69784&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69784&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69784&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69784&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69784&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69784&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69784&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69784&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69784&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69784&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69784&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69784&r=mysqlcfg
Thread (8 messages)
- artur at salonstron dot pl