ID:               28893
 Comment by:       rodolfo at rodsoft dot org
 Reported By:      bf at mediaspace dot net
 Status:           Open
 Bug Type:         Class/Object related
 Operating System: Linux
 PHP Version:      5.0.0RC3
 New Comment:

I've experienced something similar with 'clone' when the cloned
variable is used in mysqli_bind_result, as I said in bug #28870.


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

[2004-06-23 13:56:21] bf at mediaspace dot net

Description:
------------
If using "new" in a for-loop it seems that the same instance is re-used
all the time. This is not what is expected, because in terms of OOP the
new-operator schould create a new instance every time.

Tested with 4.3.3 and 5.0RC3

Reproduce code:
---------------
<?
class Test {
    var $iterator;
}

$a=array();

for($i=0;$i<10;$i++) {
    $object = new Test();
    $object->iterator=$i;
    $a[]=&$object;
}

foreach($a as $object) {
    echo $object->iterator."<br>";
}

?>

Expected result:
----------------
Output should be:

0
1
2
3
4
5
6
7
8
9


Actual result:
--------------
Output actual is:

9
9
9
9
9
9
9
9
9
9

-> The same instance is reused all the time.


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


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

Reply via email to