php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5532 Aliasing to array element affecting value downstream
Submitted: 2000-07-12 13:52 UTC Modified: 2000-07-13 04:13 UTC
From: tom dot ferguson at uphs dot upenn dot edu Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Release Candidate 2 OS: WinNT 4.0
Private report: No CVE-ID: None
 [2000-07-12 13:52 UTC] tom dot ferguson at uphs dot upenn dot edu
unset($a);
unset($v);
unset($k);

$a = array('x'=>"p",'y'=>"q",'z'=>"r");

foreach($a as $k => $v){
  echo $k . " => " .$v . "<br>";
}

echo "<br>";

$v = $a['y'];
echo $v . "<br>";
echo $a['y'] . "<br>";

echo "<br>";

$v = &$a['y'];
echo $v . "<br>";
echo $a['y'] . "<br>";

echo "<br>";

reset($a);
echo $v . "<br>";
echo $a['y'] . "<br>";

echo "<br>";

foreach($a as $k => $v){
  echo $k . " => " .$v . "<br>";
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-13 04:13 UTC] stas at cvs dot php dot net
Well, yes, foreach values are not local to the loop. 
I do not think this is a bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 22:01:28 2024 UTC