ID:               28704
 User updated by:  spy at spy dot zp dot ua
 Reported By:      spy at spy dot zp dot ua
 Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: FreeBSD-4.x
 PHP Version:      4.3.6
 New Comment:

Of course, I have checked manual, much more then twice.

Sorry, if you have no enough time to understand, that it is either real
bug, or a problem to be discussed and solved. And I have no time to dig
into source code to find out causes.


Previous Comments:
------------------------------------------------------------------------

[2004-06-30 03:43:59] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

See http://bugs.php.net/bug.php?id=20993&edit=3

------------------------------------------------------------------------

[2004-06-09 01:34:02] spy at spy dot zp dot ua

Description:
------------
As shown in this example, the elements of $a become a references during
"for" cycle, although there are not have any aliases to their values.
If we make a copy ($b=$a) of an array, it becomes an array of
references too.
And only if we unset the copy ($b), engine founds that $a elements are
not really referenced by another vars.

The same result we can get with foreach($a), (because foreach works
with a copy of an array as noted in Bug #24486)

BTW, how can I make a really clean COPY of an array, including all of
it elements? And it should be useful to have a method to test if
variable have a reference(s).

Reproduce code:
---------------
$a = array(1, 2, 3);

for ($i = 0; $i < count($a); $i++) {
    $x =& $a[$i];
}
$x=&$nowhere;

print "Dump 1 =>"; var_dump($a);
$b=$a;
$b['0']=6; $b['1']=7; $b['2']=8;

print "Dump 2 =>"; var_dump($a);

unset($b); 

print "Dump 3 =>"; var_dump($a);



Expected result:
----------------
I don't know what to expect at all now =)

Before today I should expect all dumps like this:
Dump * =>array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}


Actual result:
--------------
Dump 1 =>array(3) {
  [0]=>
  &int(1)
  [1]=>
  &int(2)
  [2]=>
  &int(3)
}
Dump 2 =>array(3) {
  [0]=>
  &int(6)
  [1]=>
  &int(7)
  [2]=>
  &int(8)
}
Dump 3 =>array(3) {
  [0]=>
  int(6)
  [1]=>
  int(7)
  [2]=>
  int(8)
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28704&edit=1

Reply via email to