#40509 [NEW]: key() function changed behaviour if global array is used within function
| From: | alex dot killing at gmx dot de | Date: | Fri, 16 Feb 2007 15:24:37 +0000 |
| Subject: | #40509 [NEW]: key() function changed behaviour if global array is used within function | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-109031@lists.php.net to get a copy of this message | ||
From: alex dot killing at gmx dot de
Operating system: MaxOsX/RedHat
PHP version: 5.2.1
PHP Bug Type: Arrays related
Bug description: key() function changed behaviour if global array is used within function
Description:
------------
If a global array is assigned to a local variable as in the example, and
the local variable is iterated afterwards, the key() function changed the
behaviour in the global scope with PHP 5.2.1.
Reproduce code:
---------------
<?php
function foo()
{
global $arr;
$c = $arr["v"];
foreach ($c as $v) {}
}
$arr["v"] = array("a");
echo "-".key($arr["v"])."-"; // prints "0"
foo();
echo "<br/>-".key($arr["v"])."-"; // prints "" since
5.2.1 ("0" on all
prior versions)
?>
Expected result:
----------------
-0-
-0-
Actual result:
--------------
-0-
--
--
Edit bug report at http://bugs.php.net/?id=40509&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40509&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40509&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40509&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40509&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40509&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40509&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40509&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40509&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40509&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40509&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40509&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40509&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40509&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40509&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40509&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40509&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40509&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40509&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40509&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40509&r=mysqlcfg